Skip to content

Commit 6388314

Browse files
committed
Merge pull request godotengine#97645 from adamscott/fix-pwa-reloading-page
Fix web export infinite reload issue
2 parents 5410000 + 4431af9 commit 6388314

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

misc/dist/html/full-size.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,11 @@
164164
new Promise((resolve) => {
165165
setTimeout(() => resolve(), 2000);
166166
}),
167-
]).catch((err) => {
168-
console.error('Error while registering service worker:', err);
169-
}).then(() => {
167+
]).then(() => {
168+
// Reload if there was no error.
170169
window.location.reload();
170+
}).catch((err) => {
171+
console.error('Error while registering service worker:', err);
171172
});
172173
} else {
173174
// Display the message as usual

platform/web/export/export_plugin.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ Error EditorExportPlatformWeb::_add_manifest_icon(const String &p_path, const St
214214
}
215215

216216
Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_preset, const String p_path, const Vector<SharedObject> &p_shared_objects) {
217+
List<String> preset_features;
218+
get_preset_features(p_preset, &preset_features);
219+
217220
String proj_name = GLOBAL_GET("application/config/name");
218221
if (proj_name.is_empty()) {
219222
proj_name = "Godot Game";
@@ -239,7 +242,10 @@ Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_prese
239242
cache_files.push_back(name + ".icon.png");
240243
cache_files.push_back(name + ".apple-touch-icon.png");
241244
}
242-
cache_files.push_back(name + ".worker.js");
245+
246+
if (preset_features.find("threads")) {
247+
cache_files.push_back(name + ".worker.js");
248+
}
243249
cache_files.push_back(name + ".audio.worklet.js");
244250
cache_files.push_back(name + ".audio.position.worklet.js");
245251
replaces["___GODOT_CACHE___"] = Variant(cache_files).to_json_string();

0 commit comments

Comments
 (0)