Skip to content

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Sep 10, 2024

In SINGLE_FILE mode, the JS is inlined directly into the generated HTML. However for pthreads builds we need to be able to create workers that use the same inlined JS. To enable this we encode the JS file into a data URL that can be used for the script src attribute. The pthread worker can then use this src.

Prior to this change using SINGLE_FILE + PTHREADS + html output would simply fail.

@sbc100 sbc100 requested a review from juj September 10, 2024 01:07
@sbc100 sbc100 force-pushed the pthread_single_file branch from c5af97c to fe7e58e Compare September 10, 2024 01:27
@sbc100 sbc100 requested a review from kripken September 10, 2024 01:27
@juj
Copy link
Collaborator

juj commented Sep 10, 2024

My god, what a monstrosity. LGTM.

@sbc100
Copy link
Collaborator Author

sbc100 commented Sep 10, 2024

My god, what a monstrosity. LGTM.

The power of the web! :) I also find this kind of horrifying by I guess we have users that really like shipping just a single file? Do you guys use this feature?

@juj
Copy link
Collaborator

juj commented Sep 10, 2024

I use SINGLE_FILE in my personal projects and often when bundling test cases to bug trackers. At Unity we did use SINGLE_FILE in a past project, but my understanding is that it is no longer active. The main Unity engine in general does not use SINGLE_FILE, though we do get repeated requests to add support for it, due to ads ecosystem MRAID architecture, which is a "single file" deployment.

@sbc100 sbc100 force-pushed the pthread_single_file branch 3 times, most recently from ab6083f to 9ab991a Compare September 10, 2024 20:34
In SINGLE_FILE mode, the JS is inlined directly into the generated
HTML.  However for pthreads builds we need to be able to create workers
that use the same inlined JS. To enable this we encode the JS file
into a data URL that can be used for the script `src` attribute.  The
pthread worker can then use this `src`.
@sbc100 sbc100 force-pushed the pthread_single_file branch from 9ab991a to 7f67200 Compare September 10, 2024 22:16
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Nice hack!

@sbc100 sbc100 enabled auto-merge (squash) September 11, 2024 18:43
@sbc100 sbc100 merged commit d9c260d into emscripten-core:main Sep 11, 2024
28 checks passed
@sbc100 sbc100 deleted the pthread_single_file branch September 11, 2024 18:48
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.

3 participants