summaryrefslogtreecommitdiffstats
path: root/platform/web/js
diff options
context:
space:
mode:
Diffstat (limited to 'platform/web/js')
-rw-r--r--platform/web/js/engine/config.js2
-rw-r--r--platform/web/js/engine/engine.js6
-rw-r--r--platform/web/js/libs/library_godot_os.js25
3 files changed, 22 insertions, 11 deletions
diff --git a/platform/web/js/engine/config.js b/platform/web/js/engine/config.js
index e4aec319c5..1acea70125 100644
--- a/platform/web/js/engine/config.js
+++ b/platform/web/js/engine/config.js
@@ -295,8 +295,6 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
'locateFile': function (path) {
if (!path.startsWith('godot.') && !path.startsWith('redot.')) {
return path;
- } else if (path.endsWith('.worker.js')) {
- return `${loadPath}.worker.js`;
} else if (path.endsWith('.audio.worklet.js')) {
return `${loadPath}.audio.worklet.js`;
} else if (path.endsWith('.audio.position.worklet.js')) {
diff --git a/platform/web/js/engine/engine.js b/platform/web/js/engine/engine.js
index 9718c9fd5a..211711b649 100644
--- a/platform/web/js/engine/engine.js
+++ b/platform/web/js/engine/engine.js
@@ -241,7 +241,11 @@ const Engine = (function () {
*/
installServiceWorker: function () {
if (this.config.serviceWorker && 'serviceWorker' in navigator) {
- return navigator.serviceWorker.register(this.config.serviceWorker);
+ try {
+ return navigator.serviceWorker.register(this.config.serviceWorker);
+ } catch (e) {
+ return Promise.reject(e);
+ }
}
return Promise.resolve();
},
diff --git a/platform/web/js/libs/library_godot_os.js b/platform/web/js/libs/library_godot_os.js
index 44617cbadc..6217794fb0 100644
--- a/platform/web/js/libs/library_godot_os.js
+++ b/platform/web/js/libs/library_godot_os.js
@@ -443,8 +443,12 @@ const GodotPWA = {
godot_js_pwa_cb__sig: 'vi',
godot_js_pwa_cb: function (p_update_cb) {
if ('serviceWorker' in navigator) {
- const cb = GodotRuntime.get_func(p_update_cb);
- navigator.serviceWorker.getRegistration().then(GodotPWA.updateState.bind(null, cb));
+ try {
+ const cb = GodotRuntime.get_func(p_update_cb);
+ navigator.serviceWorker.getRegistration().then(GodotPWA.updateState.bind(null, cb));
+ } catch (e) {
+ GodotRuntime.error('Failed to assign PWA callback', e);
+ }
}
},
@@ -452,12 +456,17 @@ const GodotPWA = {
godot_js_pwa_update__sig: 'i',
godot_js_pwa_update: function () {
if ('serviceWorker' in navigator && GodotPWA.hasUpdate) {
- navigator.serviceWorker.getRegistration().then(function (reg) {
- if (!reg || !reg.waiting) {
- return;
- }
- reg.waiting.postMessage('update');
- });
+ try {
+ navigator.serviceWorker.getRegistration().then(function (reg) {
+ if (!reg || !reg.waiting) {
+ return;
+ }
+ reg.waiting.postMessage('update');
+ });
+ } catch (e) {
+ GodotRuntime.error(e);
+ return 1;
+ }
return 0;
}
return 1;