Refresh driver keeps ticking at the full vsync rate while every document with a frame request is throttled
Categories
(Core :: Layout, defect)
Tracking
()
People
(Reporter: florian, Unassigned)
References
(Blocks 1 open bug)
Details
nsRefreshDriver keeps ticking at the full vsync rate while every document that wants a frame callback is throttled, and runs no callback until the throttle interval elapses. With layout.throttled_frame_rate at its default of 1, that is roughly sixty wakeups per skipped callback.
In RunVideoAndFrameRequestCallbacks, a document whose ShouldThrottleFrameRequests() is true is skipped and sets skippedAnyThrottledDoc, which re-adds RenderingPhase::AnimationFrameCallbacks to mRenderingPhasesNeeded. GetReasonsToTick() then keeps reporting HasPendingRenderingSteps, so Tick() never reaches its StopTimer() and the unthrottled timer keeps firing. The FIXME(emilio) on that block names the spot.
Profile: https://share.firefox.dev/4yF4dNf -- 55 consecutive RefreshDriverTick markers in the privileged-content process, ~16.7 ms apart, each 1-5 us of work, every one carrying exactly HasPendingRenderingSteps(Animation and video frame callbacks) and the same innerWindowID, the run ending at the next requestAnimationFrame callbacks marker. Recorded at 1 ms sampling over the end of a browser/extensions/newtab/test/browser test, Linux opt, headless.
This needs an unthrottled refresh driver sharing with a throttled document, so it is not every background tab: backgrounding a tab reaches nsRefreshDriver::SetActivity(false), and mThrottled makes tickThrottledFrameRequests true, so no document is skipped and nothing spins. What is left is an active tab holding a same-process document that ShouldThrottleFrameRequests() throttles on its own -- under a display: none or visibility: hidden embedder, scrolled out of view under layout.throttle_in_process_iframes, painting-suppressed during load, or the hidden-but-active document the profile caught.
Two candidate fixes, and the FIXME frames the choice: schedule at the throttled rate when the only reason to tick is a phase re-added because every candidate document was throttled, or gate the tick on mNextThrottledFrameRequestTick so the driver sleeps until the un-throttle point.
Description
•