dogballs/cattle-bity

refactor(render): Improve event loop to use one requestAnimationFrame for entire app

Closed this issue · 0 comments

https://stackoverflow.com/questions/17103785/multiple-requestanimationframe-performance

The requestAnimationFrame binds a function call and returns the frameID. Requesting multiple frames is NOT the same like adding multiple event listeners to an event- each of your functions is called in another frame. So if you continuously (each function recalls itself recursively) request several frames you're loosing the benefit that all updates are rendered within one frame. So even if there is a high framerate animations may not look that smooth.

https://jsperf.com/single-raf-draw-calls-vs-multiple-raf-draw-calls