-
Notifications
You must be signed in to change notification settings - Fork 30
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
Support for worker execution context #22
base: main
Are you sure you want to change the base?
Conversation
I don't get it. Is this some sort of working solution or just some bits of a failed experiment? |
This is a working solution for running Raylib.js in worker |
But does this allow to use original unmodified examples without the GameFrame() trick? |
No, this pull request only about support for worker context. But i think it is possible to do this in worker context. I can continue to work specifically on this if needed. |
I implemented my idea in a separate branch and here's what I realized:
Here is a demo https://x0k.github.io/raylib.js/ (I don't recommend checking implementations other than |
I initially experimented with OffscreenCanvas to allow compiling examples without modifying the game loop.
But now i realized that the execution of WASM code is treated like a normal function call (not a macro or micro tasks), so the worker thread will never handle user input, which is useless for many apps.
Also currently it is impossible to simply generate frames in a worker with
OffscreenCanvas
andbitmaprenderer
context, as they don't work with2d
context.So my experiment was failed, but there is a code to run lib in worker or main thread.