-
Notifications
You must be signed in to change notification settings - Fork 247
Description
Animation smoothness is a tough one, because it combines the need to measure it statistically over time, react to changes, and also not create too much overhead, either by over-measuring or over-reporting to the timeline.
Following the explainer and the several good alternatives presented there, I would suggest to go with something along the line of a bespoke observer (not a PerformanceObserver
that works on the performance timeline) that can be started, stopped, queried for statistical information, and fire events when certain thresholds have been passed.
Something like:
const observer = new FrameRateObserver();
observer.granularity = 10;
observer.start();
observer.stop();
observer.stats(options);
observer.addEventListener("change", event => { ... })
This can be built as a polyfill on top of requestAnimationFrame
, but having it in the platform can have a much lower overhead which in this case is important enough.
Hope you find this feedback helpful and please keep at it, it's a great problem to solve!