summaryrefslogtreecommitdiff
path: root/platform/javascript
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-03-29 19:03:20 +0200
committerGitHub <noreply@github.com>2021-03-29 19:03:20 +0200
commit2f2e4d65242058c08de045ba65345a9245dd5f24 (patch)
treeb3b806c918ce6d8873de3ae2edd2abfc51f1ce9b /platform/javascript
parent88f404f1ec52b14fd01edfe96a492b17be1ba389 (diff)
parentae3c9345cc5d5771bd10165e76048afc77b4015f (diff)
Merge pull request #47462 from Faless/js/4.x_init_no_promise
[HTML5] Fix Mono builds (old emcc?)
Diffstat (limited to 'platform/javascript')
-rw-r--r--platform/javascript/js/engine/engine.js28
1 files changed, 16 insertions, 12 deletions
diff --git a/platform/javascript/js/engine/engine.js b/platform/javascript/js/engine/engine.js
index 7211ebbfd8..17a8df9e29 100644
--- a/platform/javascript/js/engine/engine.js
+++ b/platform/javascript/js/engine/engine.js
@@ -101,19 +101,23 @@ const Engine = (function () {
}
const me = this;
function doInit(promise) {
- return promise.then(function (response) {
- return Godot(me.config.getModuleConfig(loadPath, new Response(response.clone().body, { 'headers': [['content-type', 'application/wasm']] })));
- }).then(function (module) {
- const paths = me.config.persistentPaths;
- return module['initFS'](paths).then(function (err) {
- return Promise.resolve(module);
+ // Care! Promise chaining is bogus with old emscripten versions.
+ // This caused a regression with the Mono build (which uses an older emscripten version).
+ // Make sure to test that when refactoring.
+ return new Promise(function (resolve, reject) {
+ promise.then(function (response) {
+ const cloned = new Response(response.clone().body, { 'headers': [['content-type', 'application/wasm']] });
+ Godot(me.config.getModuleConfig(loadPath, cloned)).then(function (module) {
+ const paths = me.config.persistentPaths;
+ module['initFS'](paths).then(function (err) {
+ me.rtenv = module;
+ if (me.config.unloadAfterInit) {
+ Engine.unload();
+ }
+ resolve();
+ });
+ });
});
- }).then(function (module) {
- me.rtenv = module;
- if (me.config.unloadAfterInit) {
- Engine.unload();
- }
- return Promise.resolve();
});
}
preloader.setProgressFunc(this.config.onProgress);