Fix race condition in browser.test_audioworklet_worker#26839
Merged
juj merged 4 commits intoemscripten-core:mainfrom May 2, 2026
Merged
Fix race condition in browser.test_audioworklet_worker#26839juj merged 4 commits intoemscripten-core:mainfrom
juj merged 4 commits intoemscripten-core:mainfrom
Conversation
5f21da3 to
05ea93f
Compare
juj
commented
May 1, 2026
| emscripten_outf("Test success (waited %.fms)", emscripten_performance_now() - start); | ||
| emscripten_wasm_worker_post_function_v(EMSCRIPTEN_WASM_WORKER_ID_PARENT, &do_exit); | ||
| break; | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
Old logic:
- Main thread races to spawn wasm worker and audio worklet threads.
- Let's assume wasm worker thread is slow to start, maybe sleeping for some time before reaching line 23.
- Meanwhile, audio worklet thread is faster, and proceeds to execute function
MessageReceivedInAudioWorkletThread(), which setsworkletToWorkerFlag = true; - Wasm worker thread resumes, and the
emscripten_futex_wait()check on line 24 returns immediately with-EWOULDBLOCKsince the memory address has valuetrueinstead of0. - The
while()loop is not entered, and the function quits without executing lines 26 and 27 at all.
…ight miss the wakeup signal that audio worklet has posted.
991e2cc to
c6ba3ee
Compare
Collaborator
Author
|
I rebased this on top of latest This PR comes out green, so I'll land this to hopefully get the If this doesn't help, then the test is flaky in Chrome, and not just consistently failing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix race condition in browser.test_audioworklet_worker where worker might miss the wakeup signal that audio worklet has posted.
Update documentation of
emscripten_futex_wait()for the different return values the function can have.