4

I read that timers on hidden tabs run with a resolution of 1 second. Thats realy a defect for me. With WebRTC browsers can build up a p2p network. For my application one of the peers functions as a server for the others. Now, if the peer whos the server hides his tab, all other clients suffer, because the server is running at 1 fps.

In my case the application is a game, and so thats not acceptable. I think with the arising of WebRTC more applications will want to make use of this pattern. Is there a solution for this problem?

If not google should fix this!

Cory Kendall
  • 7,195
  • 8
  • 37
  • 64
guenne
  • 53
  • 5

1 Answers1

1

You could utilize Web Workers. They are unaffected by the state of the tab/window and you get minimal delay.

Here is an example/time test of Web Workers + setInterval/setTimeout. In the example I have a worker that sends a message to the main page every 200 milliseconds.

From my tests when the tab is hidden I get less than 0.5 milliseconds delay per call pretty much the same as active tabs.

Let me know if you want any clarification.

Sev
  • 1,982
  • 1
  • 16
  • 27