diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-10-02 15:01:16 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-10-02 15:01:16 +0200 |
commit | 6388314dcca42ee775ad61460b3cbf56174ee94e (patch) | |
tree | c05efcbec294d80a3d29abced949063b21ca10af | |
parent | 5410000a521f7bf88d5f09b8acd96937a883eaa5 (diff) | |
parent | 4431af91538c2454a77ff5323d76de2a10b0329d (diff) | |
download | redot-engine-6388314dcca42ee775ad61460b3cbf56174ee94e.tar.gz |
Merge pull request #97645 from adamscott/fix-pwa-reloading-page
Fix web export infinite reload issue
-rw-r--r-- | misc/dist/html/full-size.html | 7 | ||||
-rw-r--r-- | platform/web/export/export_plugin.cpp | 8 |
2 files changed, 11 insertions, 4 deletions
diff --git a/misc/dist/html/full-size.html b/misc/dist/html/full-size.html index 1d76abe0a5..352046df30 100644 --- a/misc/dist/html/full-size.html +++ b/misc/dist/html/full-size.html @@ -164,10 +164,11 @@ const engine = new Engine(GODOT_CONFIG); new Promise((resolve) => { setTimeout(() => resolve(), 2000); }), - ]).catch((err) => { - console.error('Error while registering service worker:', err); - }).then(() => { + ]).then(() => { + // Reload if there was no error. window.location.reload(); + }).catch((err) => { + console.error('Error while registering service worker:', err); }); } else { // Display the message as usual diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp index 5faab74d7b..efe3c95496 100644 --- a/platform/web/export/export_plugin.cpp +++ b/platform/web/export/export_plugin.cpp @@ -214,6 +214,9 @@ Error EditorExportPlatformWeb::_add_manifest_icon(const String &p_path, const St } Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_preset, const String p_path, const Vector<SharedObject> &p_shared_objects) { + List<String> preset_features; + get_preset_features(p_preset, &preset_features); + String proj_name = GLOBAL_GET("application/config/name"); if (proj_name.is_empty()) { proj_name = "Godot Game"; @@ -239,7 +242,10 @@ Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_prese cache_files.push_back(name + ".icon.png"); cache_files.push_back(name + ".apple-touch-icon.png"); } - cache_files.push_back(name + ".worker.js"); + + if (preset_features.find("threads")) { + cache_files.push_back(name + ".worker.js"); + } cache_files.push_back(name + ".audio.worklet.js"); cache_files.push_back(name + ".audio.position.worklet.js"); replaces["___GODOT_CACHE___"] = Variant(cache_files).to_json_string(); |