Skip to content
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

Tab stalls when using matterjs and moving away from the tab for a while, probably Engine.update related #6977

Open
ubershmekel opened this issue Dec 9, 2024 · 2 comments · May be fixed by #6978 or #6983

Comments

@ubershmekel
Copy link
Contributor

ubershmekel commented Dec 9, 2024

Version

  • Phaser Version: v3.85.0
  • Operating system: Windows 11 Pro 22631.4460
  • Browser: Chrome

Description

I noticed that my phaser game was crashing when I went away from it for a while and came back to the tab.

At https://ubershmekel.github.io/bell-curve-balls/ there are a lot of balls, so the simulation step is a bit heavier than usual.

Phaser-Matter-away-problem

Example Test Code

Additional Information

Options I see:

  • Engine.update should be called while in the background
  • Do not call Engine.update to catch up when the tab becomes active, just resume the game from where it was when the tab became inactive.
  • Create some "simulation is catching up spinner UI" for when the tab becomes active again.

The relevant code is at:

@ubershmekel
Copy link
Contributor Author

ubershmekel commented Dec 9, 2024

I found a simple fix with runner.maxFrameTime though for some reason (mentioned in the PR) the maxFrameTime is not passed into the world runner when you specify it in the GameConfig. So I just added a sane default in the PR instead of fixing the data piping.

@samme
Copy link
Contributor

samme commented Dec 13, 2024

maxFrameTime needs a value in any case because some calculations in Phaser.Physics.Matter.World#update are producing NaN.

maxUpdates is also missing from the runner and should be added. Setting it would also prevent the tab stall.

samme added a commit to samme/phaser that referenced this issue Dec 15, 2024
@samme samme linked a pull request Dec 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants