Throttling requestAnimationFrame based on viewport visibility

In Blink we're considering to stop requestAnimationFrame callbacks for
documents which aren't visible[1]. This is to avoid overhead from
animations inside iframes that are outside the root viewport. Gecko
has recently implemented a similar optimization[2].

Has anyone else looked into something like this? I saw some earlier
threads about extending Page Visibility[3] to take the viewport into
account, but the scope of that change is a little larger than what
we're proposing.

The obvious compatibility risk is breaking pages that rely on an
out-of-view rAF to function. We're trying to avoid that by only
throttling cross-origin iframes -- with the hope that since there's no
synchronous way to observe rAF callbacks in those frames, sites are
less likely to rely on their timing. Does that sound reasonable?

Thanks,
- Sami

[1] https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/_SRHebxivJs
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=1145439
[3] https://lists.w3.org/Archives/Public/public-whatwg-archive/2015Mar/0229.html

Received on Wednesday, 5 August 2015 21:40:29 UTC