requestAnimationFrame() can't paused when running in background tabs
Categories
(Core :: Layout, enhancement, P3)
Tracking
()
People
(Reporter: zjffun, Unassigned)
References
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0
Steps to reproduce:
Run this https://codesandbox.io/embed/j465qw5wvv in background tabs.
Actual results:
The requestAnimationFrame() function is called.
Expected results:
Then requestAnimationFrame() function paused.
https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
Comment 2•6 years ago
|
||
Hi,
I was able to reproduce this issue on Firefox 66.0.4 (2019-05-04) and Firefox Nightly 68.0a1 (2019-05-05).
I'm assigning a component in order to involve the development team in reviewing this issue.
Thank you for your contribution!
I'm not sure who is familiar with requestAnimationFrame() implementation. Smaug, do you know?
Comment 4•6 years ago
|
||
animation frame in the background fires once per second by default.
https://searchfox.org/mozilla-central/rev/e7d9a8749303b39dadcc0e18ea0d60a570a68145/layout/base/nsRefreshDriver.cpp#97
We could consider to stop altogether.
Comment 6•6 years ago
|
||
I've been concerned about this breaking content but I notice Chrome is doing it so I guess it should be Web compatible.
requestAnimationFrame is often used in a similar way to setImmediate in node, i.e. to run something async, but as long as we run the first tick after being backgrounded we're probably less likely to break things (I'm thinking about things like where an app decides to save data on the next tick--ideally we want to let that happen before freezing the app).
Comment 7•6 years ago
|
||
I had a similar investigation about completely stopping refresh driver tick for background tab (or at least stopping after one tick) in bug 1352205. Some tests were broken due to that.
Comment 8•6 years ago
|
||
The priority flag is not set for this bug.
:mats, could you have a look please?
For more information, please visit auto_nag documentation.
Comment 9•6 years ago
|
||
This sounds like an enhancement, given that we have never historically paused RAF in background tabs, so re-categorizing as such.
Updated•3 years ago
|
Description
•