-
-
Notifications
You must be signed in to change notification settings - Fork 386
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
Emscripten: re-enable the -pthread compiler flag #9426
Conversation
Hi @oleg-derevenetz , since this version has so many issues with audio, should we disable opera music and only allow MIDI for now? After all, a web version of the engine is not what we will prioritise. |
Hi @ihhub
Well, we have to think a bit here. Perhaps we just shouldn't allow pthreads in the emscripten build yet. I thought it would help against music choking, but it doesn't - probably the web workers (which emulate threads in wasm) do not have access to the browser music engine, so SDL cannot use them to decode the music in background, or something like this... Anyway, enabling |
Hi @ihhub after some thought and tests, I suggest to enable the Please note that I added a paragraph in the PR description regarding the cross origin policy settings required to get the multithread version to work in a web browser. |
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.
Hi @oleg-derevenetz , I left few questions here. Could you please check them?
9717254
to
f29f3f7
Compare
@oleg-derevenetz , many thanks for these updates! |
emscripten-core/emscripten#23094 was merged recently, but there is no new release with these changes yet (and accordingly, there is no new docker image), so I decided to apply a temporary patch for now using our CI (it will be removed when the new Emscripten docker image will be released).
It works in general;
Background music playback is now resumed correctly (more or less, see below);
"Feeding" the player with musical chunks from MIDI/MP3/OGG decoders by SDL_mixer is still performed in the main thread, and not in the background threads, like it's done on other platforms, so the background music still chokes when the main thread is busy with something;
OGG backend periodically crashes like this:
or like this:
MP3 backend, however, seems to work correctly, except for spamming to the browser console by messages like this when the music is resumed from a previously remembered position (but resume mostly still works):
These messages are originated from the
libmpg123
backend internals:MIDI playback seems to work flawlessly.
Overall, I regard the Emscripten build as still quite unstable. It is playable, but it's very rough for now.
Also please note that Emscripten uses the
SharedArrayBuffer
to implement the cross-thread communication and synchronization.SharedArrayBuffer
needs the specific cross origin policy headers to be set by the HTTP server, namelyCross-Origin-Opener-Policy: same-origin
andCross-Origin-Embedder-Policy: require-corp
. These headers, in turn, will be accepted by a browser only if at least one of the following is true:localhost
(in this case, HTTPS is not required).