-
Notifications
You must be signed in to change notification settings - Fork 0
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
bug: collision breaks on tab switch #37
Comments
Hey ! Yes this is a known bug, switching tab (and sometimes just waiting) can break the collisions. This is top priority issue, thanks for opening it ! 👍 |
Pinning some discutions I had with @doppl3r on dimforge Discord The requestAnimationFrame calls are "paused in most browsers when running in background tabs". Stepping the physic world by Using a Web Worker for running the simulation might help. |
Decided to not use a web worker, as it is basically impossible to reliably and efficiently sync the scene's data across multiple worker + main thread 30 times per second. Doing everything in a single web worker is technically achievable however (as in react-three-offscreen) but :
For the sake of this issue, I'll keep it simple and make it so the simulation doesn't run when the tab is inactive, and ignore the time that passed. |
Describe the bug
This happens in the brand new unmodified 2D starter project. Works fine normally, but when I switch to another tab for a few seconds and come back, the little alien guy has fallen through the floor and the death barrier.
To Reproduce
Steps to reproduce the behavior :
fibbo init 2d [project-name]
npm run dev
Expected behavior
Staying on the platform?
Screenshots
Image
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: