[AUDIO_WORKLET] Wait for Wasm instance to start using audio worklet.#24734
[AUDIO_WORKLET] Wait for Wasm instance to start using audio worklet.#24734brendandahl wants to merge 3 commits intoemscripten-core:mainfrom
Conversation
| readyPromiseResolve = resolve; | ||
| readyPromiseReject = reject; | ||
| }); | ||
| moduleRtn = readyPromise = createReadyPromise(); |
There was a problem hiding this comment.
Can we just do moduleRtn = readyPromise here and unconditionally call createReadyPromise in runtime_common.js ?
There was a problem hiding this comment.
I think if I do that, I'll have to undo the work you did in https://github.com/emscripten-core/emscripten/pull/24418/files and add back a try/catch.
| if ({{{ ENVIRONMENT_IS_WORKER_THREAD() }}}) { | ||
| #if MODULARIZE | ||
| #if USE_READY_PROMISE | ||
| readyPromiseResolve?.(Module); |
There was a problem hiding this comment.
I think you can perhaps remove the question marks here too. i.e. we can make USE_READY_PROMISE imply that readyPromiseResolve exists?
This fixes intermittent test failures where the AudioWorklet was used before the Wasm module was loaded.
This is an automatic change generated by tools/maint/rebaseline_tests.py. The following (4) test expectation files were updated by running the tests with `--rebaseline`: ``` test/code_size/audio_worklet_wasm.js updated code_size/audio_worklet_wasm.json: 5660 => 5719 [+59 bytes / +1.04%] test/other/codesize/test_codesize_minimal_esm.gzsize updated test/other/codesize/test_codesize_minimal_esm.jssize updated Average change: +1.04% (+1.04% - +1.04%) ```
f61ac64 to
c3647ef
Compare
|
I'm a little wary about extending the use of the module promise outside of the existing usage in |
|
That won't work with minimal_runtime. I suppose I could use one of the other hooks like ATINITS or ATPOSTCTORS that works in regular and minimal runtime. |
|
Those hooks don't work for wasm workers, but I think i've found another way. With non minimal runtime and wasm workers a message handler is installed that queues all the messages. The cleanup code for this was being installed, but not the setup code. |
|
Closing in favor of #24778 |
This fixes intermittent test failures where the AudioWorklet was used
before the Wasm module was loaded.