Enable Wasm Workers to call pthread APIs in hybrid mode#26757
Merged
Conversation
787860e to
71028cb
Compare
juj
reviewed
Apr 23, 2026
juj
approved these changes
Apr 23, 2026
Collaborator
juj
left a comment
There was a problem hiding this comment.
Nice - was the design doc something that AI was able to work through?
Collaborator
Author
I was hoping so.. but I actually took over and did this myself, since I have strong feeling about exactly how to do it. For the first design doc |
71028cb to
fdea506
Compare
This change ends up adding ~200 bytes of data to each Wasm Worker (in hybrid mode only) to store the `struct pthread`. If the `pthread_key_create` API is used in the program then each worker needs an additional 512 bytes to store the PTHREAD_KEYS_MAX (128) pointers. This change also essentially reverts the musl patch from emscripten-core#26673 since it is no longer needed. See emscripten-core#26631
fdea506 to
f1baad4
Compare
dschuff
reviewed
Apr 23, 2026
juj
added a commit
to juj/emscripten
that referenced
this pull request
May 1, 2026
… longer feasible to run Wasm Workers with tiny stack sizes, after emscripten-core#26757 grew the used portion of the stack. Mass-convert all examples that use tiny 1KB Wasm Worker stack sizes to have a 4KB stacks. Fixes browser64.test_audioworklet_worker, which was failing due to emscripten_outf() overrunning the stack space over to atexit() data structure space. Add a runtime check to re-entrancy of exitRuntime() to detect nested re-entering back into exitRuntime() from within an atexit() handler. Closes emscripten-core#26823.
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.
This change ends up adding ~200 bytes of data to each Wasm Worker (in
hybrid mode only) to store the
struct pthread.If the
pthread_key_createAPI is used in the program then each workerneeds an additional 512 bytes to store the PTHREAD_KEYS_MAX (128)
pointers.
This change also essentially reverts the musl patch from #26673 since it
is no longer needed.
See #26631