I noted it is a browser behaviour to disable canvas rendering while the tab is switched ignoring disableVisibilityChange
as stated in it’s documentation, in this case I don’t mind if the game is paused.
However, game.time.elapsedMS
is still updated to the total time to when the tab is switched back.
Any workarounds to get game.time.elapsedMS
to “about zero” when tab is switched while disableVisibilityChange
is true?
I have tried Page Visibility API but it seems to always show the page is visible.
Update: It seems within the game update loop to check document.visibilityState
is always visible, but using the event listener visibilitychange
it will able to get the hidden state.