diff options
author | stephan <stephan@noemail.net> | 2025-01-16 09:27:40 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2025-01-16 09:27:40 +0000 |
commit | 3202b11f66aaeac6dd86f64f3d38dff9e3464b86 (patch) | |
tree | 689465a289b094ad0c75d73ad3acba2d682a5367 /ext/wasm/api/extern-post-js.c-pp.js | |
parent | c5dd908c89436a2c1006a858ea7ebed84836453b (diff) | |
download | sqlite-3202b11f66aaeac6dd86f64f3d38dff9e3464b86.tar.gz sqlite-3202b11f66aaeac6dd86f64f3d38dff9e3464b86.zip |
Replace use of Emscripten's Module.postRun() with a custom callback so that we get consistent library init timing with both Emscripten 3.1.x and 4.0.x. Details and discussion are in [https://github.com/emscripten-core/emscripten/issues/23420|Emscripten ticket #23420].
FossilOrigin-Name: 4863a70ac61ff6f868429f16f0141484ea98f973fde1a9aff879252d0f1dbb6b
Diffstat (limited to 'ext/wasm/api/extern-post-js.c-pp.js')
-rw-r--r-- | ext/wasm/api/extern-post-js.c-pp.js | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/ext/wasm/api/extern-post-js.c-pp.js b/ext/wasm/api/extern-post-js.c-pp.js index c54e1f082..3598c0d6f 100644 --- a/ext/wasm/api/extern-post-js.c-pp.js +++ b/ext/wasm/api/extern-post-js.c-pp.js @@ -65,15 +65,14 @@ const toExportForESM = return originalInit(...args).then((EmscriptenModule)=>{ //console.warn("originalInit() then() arg =",EmscriptenModule); //console.warn("initModuleState =",initModuleState); - if( EmscriptenModule.postRun && EmscriptenModule.postRun.length ){ - /* Emscripten 4.0.0 changes the order in which our Module.postRun handler - runs. In 3.x postRun would have run by now, and our code relies - heavily on that order, so we'll work around that difference here. - - https://github.com/emscripten-core/emscripten/issues/23420 */ - //console.warn("Emscripten did not run postRun: running them now!"); - EmscriptenModule.postRun.shift()(EmscriptenModule); - } + EmscriptenModule.runSQLite3PostLoadInit(EmscriptenModule); + const s = EmscriptenModule.sqlite3; + s.scriptInfo = initModuleState; + //console.warn("sqlite3.scriptInfo =",s.scriptInfo); + if(ff.__isUnderTest) s.__isUnderTest = true; + const f = s.asyncPostInit; + delete s.asyncPostInit; + const rv = f(); //#if wasmfs if('undefined'!==typeof WorkerGlobalScope && EmscriptenModule['ENVIRONMENT_IS_PTHREAD']){ @@ -86,13 +85,7 @@ const toExportForESM = return EmscriptenModule; } //#endif - const s = EmscriptenModule.sqlite3; - s.scriptInfo = initModuleState; - //console.warn("sqlite3.scriptInfo =",s.scriptInfo); - if(ff.__isUnderTest) s.__isUnderTest = true; - const f = s.asyncPostInit; - delete s.asyncPostInit; - return f(); + return rv; }).catch((e)=>{ console.error("Exception loading sqlite3 module:",e); throw e; |