Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign uprequestAnimationFrame is called ~1500 times per second #7782
Comments
|
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 |
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? |
|
@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 @pcwalton Does that sound correct to you? |
|
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. |
|
@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. |
|
@glennw Oh, so we have vsync support already? |
|
@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. |
|
I'm a bit lost. If 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 |
|
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 |
|
If |
|
Now we are more advanced in browser.html support, this ends up being a problem. Many animations in browser.html are RAF driven, and having ~700 calls per seconds is really impacting the performance. |
It's called 60 FPS. |
|
I think this will be a lot easier to solve with the WR design than the existing layers / painting design - I'll look into once I've cleared out my current bug list. |
|
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. |
|
@glennw on osx, I'm still getting ~500 calls. |
|
It sounds like maybe vsync isn't working? Is there any way to verify if an application is running with vsync enabled? |
|
I added to comment 0 the script I use to count the FPS. |
|
I tried that test case on Linux and it's reporting 60 fps (well 61-62 but close enough for this test). |
|
vsync is enabled on mac (at least, glutin's |
|
Actually - I was wrong. It runs at 60 FPS. |
|
I figured it out. Using the |
|
@paulrouget Can we close this in favor of #9431? |
|
Sorry, I meant when #9401 lands. |
|
(not a browserhtml-P1 anymore as it has been fixed in webrender) |
Which is a little bit too much :)