-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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: Support running SDL programs in a web worker #11264
Comments
This would be ugly code that is difficult to maintain, with a million things that silently break when done in a background thread, waiting to surprise everyone. If a reasonable PR were to appear, I'd accept it, but I don't think we're going to work on this otherwise. |
Maybe it'd make sense for pygame to be structured to support that for everyone instead? In LÖVE its main loop is a function that gets run by a coroutine under the hood, for example. It wasn't a big deal for users to switch to that when we made that change, although most new users don't end up modifying its default main loop. |
If you can make something that works with the main callbacks API in SDL 3, the same code will work on desktop and emscripten without any changes. |
Currently the SDL implementation in Emscripten assumes it is running on the main thread, according to the SDL Emscripten README. This is a problem because most SDL-based programs have an infinite main loop which assumes it can update the UI synchronously, and must be rewritten to explicitly yield to the browser main loop to run in Emscripten.
If SDL could be made to run in a web worker instead, communicating with the main thread as needed, it would remove the need to rewrite the main loop. Then most SDL-based programs could be run unmodified in the browser.
Applications:
screen
in a similar fashion from SDL in a web worker to a main thread.The text was updated successfully, but these errors were encountered: