[whatwg] Proposal: requestBackgroundProcessing()

Tab Atkins Jr. jackalmage at gmail.com
Thu Feb 20 08:18:55 PST 2014

On Thu, Feb 20, 2014 at 7:25 AM, Ashley Gullen <ashley at scirra.com> wrote:
> We're building a browser-based P2P multiplayer engine on top of WebRTC
> DataChannels. You can try out our work-in-progress here:
> http://www.scirra.com/labs/multiplayer/test1/
> The first player in to a room is assigned the host, and all other
> subsequently joining peers connect to the host with WebRTC DataChannels and
> start exchanging game data. Like all responsible HTML5 games, it runs based
> on a requestAnimationFrame loop.

I think this is your problem.  rAF isn't a replacement for setTimeout,
it's a variant designed to better solve the timer problem *when you
want to be synced to the screen*.

If you're doing network-management work, that has nothing to do with
the screen refresh rate, and shouldn't be associated with it.  Just
run a normal setTimeout loop instead.

(If people used rAF for what it was *intended* for, we could probably
have stopped firing it *entirely* when the window isn't visible.
Instead, we had to compromise with the 1s refresh rate instead.)


More information about the whatwg mailing list