What does Phaser 3 do when you go over to another tab? Is there any way to stop it being paused?
I have a game dependent on the real world time that is ascertained from async calls to the blockchain, and when I tab back, it can give me some really bugs, showing things that should be hidden. If I keep Phaser 3 always on the tab, these bugs never happen.
You cannot avoid the game being paused. Modern browsers throttle or pause code execution of inactive tabs for performance reasons.
It is on you to ensure this doesn’t cause problems. You can detect a pause in your update loop and handle it appropriately, e.g. by simulating the missed frames in that time span.
I guess I should rephase the question now that I’ve debugged with timestamps. The clocks are actually continuing to count and run when not active, but the if a tween gets called (there’s some setIntervals of tweens to sync order and sound), the tween continues to play when you come back to the tab, regardless of the state.
Is there an example of killing a tween if it’s not finished in a certain amount of time so that it doesn’t play when someone tabs back?
I’m trying to avoid using the update loop in this case, although using it is one good way to make sure users tab back, because it destroys my macbook’s CPU and fans.
The game is only recursive async calls to a blockchain.
Try the FOCUS or VISIBLE events.