-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Run bevy systems in wasm even when the tab is not focused #13368
Comments
To add to this, while unfocused, bevy could run in headless mode (meaning no user io / rendering and input need to be collected). Implementation wise this could make use of various web-apis such as setTimeout, setInterval, requestIdleCallback, queueMicrotask and Web Workers. |
For posterity...
https://discord.com/channels/691052431525675048/750833140746158140/1240217724354039858 It seems this is achievable right now by using |
For this specific problem, I think web workers might be best. Spawning a web worker and having it run the Unfortunately, at this point, Although, the issue that originally implemented scheduler with setTimeout fallback mentions a trick that might explain the results I was seeing with Not sure I understand what that trick is. 🙂 Maybe it's also related to the Also, regarding vsync and |
https://github.com/Nul-led/bevy_web_keepalive/tree/main fixes this issue for now |
The comment in Winit is on Winit uses
I think using Web Workers for This would all be unrelated to
Winit doesn't use But both the
Keep in mind that rust-windowing/winit#2880 was reverted in rust-windowing/winit#3044 and |
I was only trying to say that, when the comment was written, the only option to avoid throttling (without a winit change) was to use scheduler and |
To clarify: the
This is now implemented in rust-windowing/winit#3739 and should be released in Winit v0.30.3 soon. |
What problem does this solve or what need does it fill?
It seems like if the user switches to a different tab, the bevy app will basically freeze and stop getting updated.
This seems to be because running the schedule in wasm is tied to
requestAnimationFrame
(https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame) calls which are made by winit in the winit_runner.A potential solution would be:
The text was updated successfully, but these errors were encountered: