You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
requestAnimationFrame is called ~1500 times per second #7782
Yep - I ran across this yesterday. The callback is triggered whenever the compositor runs, which is as fast as possible when animations are running (which is also wrong). Instead, it should only trigger the callback after an entire paint completes for the relevant pipeline. This is a little bit tricky, since it needs to check the epoch for each layer that is painted for the pipeline in question.
@glennw I'd like to work on this, if you can give me a hand.
I am trying to understand to follow the chain that triggers the callback. As I understand, this goes through ConstellationControlMsg::TickAllAnimations, which we want to send less often. In turn this goes through LayoutControlMsg::TickAnimations, ConstellationControMsg::TickAnimations and to change_running_animations_state. Is this where we want to throttle the callback or should I climb the chain a little bit further?
The callback is triggered whenever the compositor runs, which is as fast as possible when animations are running (which is also wrong).
In my case, there was no animation.
Instead, it should only trigger the callback after an entire paint completes for the relevant pipeline.
What is wrong with keeping the same strategy (RFA when the compositor runs), but driving the compositor with vsync? Isn't that how it's supposed to work?
@paulrouget If we drive it with vsync we could get extra callbacks when the repainting is taking longer than a vsync period, and we should also support running in non-vsync mode correctly, I think.
@Yoric Great! I think what we want to do is throttle the callback in process_animations which is called each time the compositor draws a frame - in such a way that it only ticks animations if there isn't an outstanding paint being waited on for the relevant pipeline.
According to my trusty Gecko Compositor hacker @nical, we should really drive it with vsync. Preventing double-callbacks shouldn't be too hard, I guess.
@glennw Why do we want to support non-vsync mode, btw?
Non-vsync mode is useful if you want to benchmark layout or rendering performance, but it's important for frame uniformity to drive RaF from vsyncs in the general case. Better yet, detecting that we are not keeping up with vsync and skipping every other vsyncs when that happens to keep frames uniforms (or when we want to save energy) is pretty useful.
It should not be hard to avoid the extra callback problem (you more or less just need to ignore incoming vsync notifications when you have a vsync callback that hasn't completed yet).
@Yoric Yep, exactly what nical said. I should have been clearer in saying that driving it from vsync is what we want, we just need to take account of those edge cases (vsync disabled, and painting not keeping up with vsync) and make sure they work too.
I'm a bit lost. If process_animations is called 1500 times per second, then so are process_pending_scroll_events and window.present() (which I understand is window flipping: documentation needed), so I guess we need to throttle all of these to vsync. Are you telling me that this is probably already the case at least on Linux?
If so, your earlier comment is a fallback for platforms that do not have vsync, right? I'm not sure I understand why finding out if the pipeline is waiting for a paint is related to the issue at hand (unless that's the vsync?) but I can certainly investigate this. Is this what does_layer_have_outstanding_paint_messages does or should I look on the other side of the pipeline?
I pushed glennw@be3213e to the WR servo branch. In my test case, with vsync enabled (which is the default), I am getting rAF callbacks at exactly 60 fps, synced with the presentation interval.
I've also opened a PR to submit this to upstream servo here - #9401 - however even once this lands upstream there may be issues with non-WR painting backend in some cases.
Activity
glennw commentedon Sep 29, 2015
Yep - I ran across this yesterday. The callback is triggered whenever the compositor runs, which is as fast as possible when animations are running (which is also wrong). Instead, it should only trigger the callback after an entire paint completes for the relevant pipeline. This is a little bit tricky, since it needs to check the epoch for each layer that is painted for the pipeline in question.
Yoric commentedon Sep 29, 2015
@glennw I'd like to work on this, if you can give me a hand.
I am trying to understand to follow the chain that triggers the callback. As I understand, this goes through
ConstellationControlMsg::TickAllAnimations, which we want to send less often. In turn this goes throughLayoutControlMsg::TickAnimations,ConstellationControMsg::TickAnimationsand tochange_running_animations_state. Is this where we want to throttle the callback or should I climb the chain a little bit further?paulrouget commentedon Sep 29, 2015
In my case, there was no animation.
What is wrong with keeping the same strategy (RFA when the compositor runs), but driving the compositor with vsync? Isn't that how it's supposed to work?
glennw commentedon Sep 29, 2015
@paulrouget If we drive it with vsync we could get extra callbacks when the repainting is taking longer than a vsync period, and we should also support running in non-vsync mode correctly, I think.
@Yoric Great! I think what we want to do is throttle the callback in
process_animationswhich is called each time the compositor draws a frame - in such a way that it only ticks animations if there isn't an outstanding paint being waited on for the relevant pipeline.@pcwalton Does that sound correct to you?
Yoric commentedon Sep 30, 2015
According to my trusty Gecko Compositor hacker @nical, we should really drive it with vsync. Preventing double-callbacks shouldn't be too hard, I guess.
@glennw Why do we want to support non-vsync mode, btw?
nical commentedon Sep 30, 2015
Non-vsync mode is useful if you want to benchmark layout or rendering performance, but it's important for frame uniformity to drive RaF from vsyncs in the general case. Better yet, detecting that we are not keeping up with vsync and skipping every other vsyncs when that happens to keep frames uniforms (or when we want to save energy) is pretty useful.
It should not be hard to avoid the extra callback problem (you more or less just need to ignore incoming vsync notifications when you have a vsync callback that hasn't completed yet).
glennw commentedon Sep 30, 2015
@Yoric Yep, exactly what nical said. I should have been clearer in saying that driving it from vsync is what we want, we just need to take account of those edge cases (vsync disabled, and painting not keeping up with vsync) and make sure they work too.
Yoric commentedon Oct 1, 2015
@glennw Oh, so we have vsync support already?
glennw commentedon Oct 1, 2015
@Yoric Only in so much as (I think) we set the default swap interval to vsync - it may even just be that it defaults to vsync on my linux machine.
Yoric commentedon Oct 2, 2015
I'm a bit lost. If
process_animationsis called 1500 times per second, then so areprocess_pending_scroll_eventsandwindow.present()(which I understand is window flipping: documentation needed), so I guess we need to throttle all of these to vsync. Are you telling me that this is probably already the case at least on Linux?If so, your earlier comment is a fallback for platforms that do not have vsync, right? I'm not sure I understand why finding out if the pipeline is waiting for a paint is related to the issue at hand (unless that's the vsync?) but I can certainly investigate this. Is this what
does_layer_have_outstanding_paint_messagesdoes or should I look on the other side of the pipeline?nical commentedon Oct 2, 2015
Yoric already knows about this document, but for the record, here is the design doc of the vsync stuff in gecko: https://dxr.mozilla.org/mozilla-central/source/gfx/doc/Silk.md
Resolves servo#7782 - Composite data only if the target is ready to r…
7 remaining items
glennw commentedon Jan 22, 2016
I pushed glennw@be3213e to the WR servo branch. In my test case, with vsync enabled (which is the default), I am getting rAF callbacks at exactly 60 fps, synced with the presentation interval.
I've also opened a PR to submit this to upstream servo here - #9401 - however even once this lands upstream there may be issues with non-WR painting backend in some cases.
paulrouget commentedon Jan 22, 2016
@glennw on osx, I'm still getting ~500 calls.
glennw commentedon Jan 22, 2016
It sounds like maybe vsync isn't working? Is there any way to verify if an application is running with vsync enabled?
paulrouget commentedon Jan 22, 2016
I added to comment 0 the script I use to count the FPS.
glennw commentedon Jan 22, 2016
I tried that test case on Linux and it's reporting 60 fps (well 61-62 but close enough for this test).
paulrouget commentedon Jan 25, 2016
vsync is enabled on mac (at least, glutin's
WindowBuilder::with_vsyncis called).paulrouget commentedon Jan 26, 2016
Actually - I was wrong. It runs at 60 FPS.
Sorry sorry. I must have run a release build and compiled a debug build.
paulrouget commentedon Jan 26, 2016
I figured it out. Using the
-boption makes the FPS go crazy. Not using-b, it goes at 60 FPS.paulrouget commentedon Jan 26, 2016
#9431
pcwalton commentedon Jan 27, 2016
@paulrouget Can we close this in favor of #9431?
paulrouget commentedon Jan 27, 2016
@pcwalton This issue will get fixed once #9244 lands.
paulrouget commentedon Jan 27, 2016
Sorry, I meant when #9401 lands.
paulrouget commentedon Jan 28, 2016
(not a browserhtml-P1 anymore as it has been fixed in webrender)