Skip to content

[WASM_WORKERS] Inline .ww.js file into the main output .js file #24163

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

Merged
merged 1 commit into from
Apr 25, 2025

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Apr 21, 2025

Similar to what we did for pthreads in #21701.

This is win for both code size and complexity. Importantly it avoid the issue how to package and deploy the extra .ww.js file.

This also completely removes the need for the -sWASM_WORKERS=2 mode.

@sbc100 sbc100 marked this pull request as draft April 21, 2025 22:48
@sbc100 sbc100 changed the title Inline ww.js file into the main output file [WIP] Inline ww.js file into the main output file Apr 21, 2025
@sbc100 sbc100 force-pushed the wasm_worker_single_file branch from 02fe7c8 to c823cd9 Compare April 22, 2025 00:08
@RReverser
Copy link
Collaborator

Very happy to see this happening, thanks for working on it!

I think conceptually .aw.js are also very similar, I gave a stab to trying to inline them before, but the amount of changes was getting out of hand (now I see why from this diff, it does require quite a bit of work). Do you think they could be also covered in or after this PR?

@sbc100
Copy link
Collaborator Author

sbc100 commented Apr 22, 2025

Very happy to see this happening, thanks for working on it!

I think conceptually .aw.js are also very similar, I gave a stab to trying to inline them before, but the amount of changes was getting out of hand (now I see why from this diff, it does require quite a bit of work). Do you think they could be also covered in or after this PR?

I think may be possible, but would likely be a followup.

@sbc100 sbc100 force-pushed the wasm_worker_single_file branch from c823cd9 to 65b40c8 Compare April 23, 2025 21:37
@sbc100 sbc100 changed the title [WIP] Inline ww.js file into the main output file Inline ww.js file into the main output file Apr 23, 2025
@sbc100 sbc100 requested review from RReverser, kripken and dschuff April 23, 2025 21:49
@sbc100 sbc100 changed the title Inline ww.js file into the main output file [WASM_WORKERS] Inline ww.js file into the main output file Apr 23, 2025
@sbc100 sbc100 marked this pull request as ready for review April 23, 2025 21:51
@sbc100 sbc100 force-pushed the wasm_worker_single_file branch 3 times, most recently from 7ba347e to b74a829 Compare April 23, 2025 21:55
@sbc100 sbc100 force-pushed the wasm_worker_single_file branch from b74a829 to 081ac97 Compare April 23, 2025 22:41
@sbc100 sbc100 force-pushed the wasm_worker_single_file branch 3 times, most recently from 61dd4db to 6d8ef34 Compare April 24, 2025 00:27
Copy link
Collaborator

@RReverser RReverser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is further cleanup that could be made here (eg replacing onmessage = with addEventListener / removeEventListener to merge more polyfills together) but those can be left for future PRs.

LGTM % CI fixes.

@juj
Copy link
Collaborator

juj commented Apr 24, 2025

What is the origin that the Worker gets loaded from after this change? Is it in the same origin? Also, does this retain csp-eval safety?

@RReverser
Copy link
Collaborator

@juj The worker is the main JS file itself, so the origin and CSP properties should remain the same, since you needed to load main JS before this PR as well (without it nothing works).

@sbc100 sbc100 force-pushed the wasm_worker_single_file branch 3 times, most recently from 8773c80 to 14a2674 Compare April 24, 2025 22:11
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 25, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 25, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 25, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 25, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 25, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 25, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 25, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 25, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 25, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 25, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 28, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 28, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 28, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 28, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 28, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 28, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 28, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 28, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 28, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 29, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 29, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Apr 29, 2025
This is similar to what we already did for pthreads (emscripten-core#24163) and normal
wasm workers (emscripten-core#24163).  By integrating this file we can actually share
more startup code with normal wasm workers.
sbc100 added a commit that referenced this pull request Apr 29, 2025
…24190)

This is similar to what we already did for pthreads (#24163) and normal
wasm workers (#24163). By integrating this file we can also share
more startup code with normal wasm workers.
sbc100 added a commit to sbc100/emscripten that referenced this pull request May 1, 2025
Now that the wasm worker code is always in the same file as the main
JS code there is no need to quote or minify these names.  See emscripten-core#24163.
sbc100 added a commit to sbc100/emscripten that referenced this pull request May 1, 2025
Now that the wasm worker code is always in the same file as the main
JS code there is no need to quote or minify these names.  See emscripten-core#24163.
sbc100 added a commit to sbc100/emscripten that referenced this pull request May 1, 2025
Now that the wasm worker code is always in the same file as the main
JS code there is no need to quote or minify these names.  See emscripten-core#24163.
sbc100 added a commit to sbc100/emscripten that referenced this pull request May 1, 2025
Now that the wasm worker code is always in the same file as the main
JS code there is no need to quote or minify these names.  See emscripten-core#24163.
sbc100 added a commit to sbc100/emscripten that referenced this pull request May 5, 2025
Now that the wasm worker code is always in the same file as the main
JS code there is no need to quote or minify these names.  See emscripten-core#24163.
sbc100 added a commit that referenced this pull request May 5, 2025
Now that the wasm worker code is always in the same file as the main JS
code there is no need to quote or minify these names. See #24163.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants