[Proposal] AnimationFrameProvider.requestPostAnimationFrame

#1

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

Explainer

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

1 Like

#2

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

#3

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

0 Likes

#4

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.

0 Likes

#5

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.

0 Likes