1

I'm making a HTML5 game (with WebSockets) and frequent health bar updates are delivered. When I go to another application and return to the game later, all these updates are applied at once, so the health bar just goes up/down constantly for 30 seconds.

I believe that this is due to the browser giving the tab less processing time because it isn't active (so then the packets all queue up and are processed when I re-visit the tab or window).

Is there any good way of telling when a tab is slowed down like this? I'd like to detect this so that the game can automatically pause and stop receiving (then useless) packets.

This question is different from the one linked here because when a user switches tabs, the CPU time of that tab isn't immediately reduced to a tiny amount. For example, I can quickly switch tabs to look at reddit and come back after a few seconds without an issue of packet build-up.

Lucien
  • 776
  • 3
  • 12
  • 40
  • Possible duplicate of [Javascript to detect if user changes tab](https://stackoverflow.com/questions/10338704/javascript-to-detect-if-user-changes-tab) – StudioTime Jun 01 '18 at 12:36

0 Answers0