Open Bug 1548561 Opened 6 years ago Updated 2 years ago

requestAnimationFrame() can't paused when running in background tabs

Categories

(Core :: Layout, enhancement, P3)

enhancement

Tracking

()

Tracking Status
firefox66 --- affected
firefox67 --- affected
firefox68 --- affected

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

I'm using the FireFox 66.0.3 (64 bit) for testing.

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!

Status: UNCONFIRMED → NEW
Component: Untriaged → DOM: Core & HTML
Ever confirmed: true
Product: Firefox → Core
Version: 66 Branch → Trunk

I'm not sure who is familiar with requestAnimationFrame() implementation. Smaug, do you know?

Flags: needinfo?(bugs)

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.

Component: DOM: Core & HTML → Layout
Flags: needinfo?(bugs)

Brian, opinions?

Flags: needinfo?(bbirtles)

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).

Flags: needinfo?(bbirtles)

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.

See Also: → 1352205

The priority flag is not set for this bug.
:mats, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(mats)

This sounds like an enhancement, given that we have never historically paused RAF in background tabs, so re-categorizing as such.

Type: defect → enhancement
Flags: needinfo?(mats)
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.