-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Avoid calling addEventListener
in audio worklet
#21897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid calling addEventListener
in audio worklet
#21897
Conversation
3c4c631
to
af002d5
Compare
I might be good to add a test for this to test_browser.py (a test that uses audio worklets and wasm workers together). |
I just added a test that uses audio worklets and workers at the same time. Thanks for the quick reviews! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@juj could you take a look too?
Great work on the test. LGTM with a small update. |
When building an application that uses both an audio worklet and a normal worker, the main module wrapper (
a.out.js
) callsaddEventListener
wheneverENVIRONMENT_IS_WASM_WORKER
. This flag is set for audio worklets, butaddEventListener
is not available in the audio worker global scope. The audio worklet load process then fails.This doesn't occur when using only the audio worklet APIs, because
_emscripten_create_wasm_worker__postset
doesn't happen. There's already a check to prevent a similar error just above the lines modified by this PR: https://github.com/emscripten-core/emscripten/blob/fa80cf25b8641974d60605b8a24cb7150fd63701/src/library_wasm_worker.js#L112C5-L112C58 so the missing check here seems like an oversight.Here's a minimal example that reproduces the failure:
Build with
emcc -sAUDIO_WORKLET=1 -sWASM_WORKERS=1 example.cc