[Proposal] AnimationFrameProvider.requestPostAnimationFrame


AnimationFrameProvider.requestPostAnimationFrame will act as a bookend to AnimationFrameProvider.requestAnimationFrame.


This has been a frequently requested feature by web developers that want finer controls for scheduling javascript around rendering deadlines.

1 Like

Question: Does this mean that getBoundingClientRect etc. comes with no cost because the browser has just drawn the dimensions? That would be great!

1 Like

Is this a better or worse place for canvas apps drawing at 60FPS to make their calls compared to the normal requestAnimationFrame?


Yes, that’s correct, although you should keep in mind that you can only get the results after the object has already been displayed. So it may not work for driving layout; you may get a frame of bad pixels.


Potentially yes; a lot depends on the structure of your application. But in general, the advantage of drawing to the canvas from requestPostAnimationFrame is that you get the maximum possible runway for doing that work before the next frame deadline. So, for example, if your canvas code takes 8ms to run, then running it from requestPostAnimationFrame gives you the greatest possibility of not exceeding the rendering deadline.


The was discussed at the WebPerfWG and got positive feedback from all browser vendors. The resolution was to explicitly move this repo to the WICG so that other vendors can provide feedback.

Let’s do this!


I’m curious what the implication of rendering in rPAF has for input event latency. It sounds like rPAF gives more time to meet rendering deadlines, but when are input events delivered? I’ve heard of “rAF aligned input events” which deliver input events just before rAF, but rendering in rPAF means rendering just before input events are delivered. This sounds like it means the app just misses input events, and therefore gets an unnecessary extra frame of input delay.

It would be nice if we could figure out an approach that uses rPAF for most rendering runway and has the lowest possible input latency.


The repo now lives on https://github.com/WICG/requestPostAnimationFrame

Happy incubation!!!