[web-animations] Sampling optimization

If I understand the spec correctly, in the case of keyframe effects, an UA is expected to periodically update all keyframe effects. Upon being requested to update itself, a keyframe effect then queries the animation (who in turn queries the document timeline) to get time fraction and current iteration, and finally apply css properties or dom attributes to the target element accordingly.

This whole process has one premise: the UA needs to periodically update all keyframe effects *unconditionally*. However in reality, the UA, after updating all keyframe effects, can check if any associated animation is still in running play state, if not, it can stop periodically updating keyframe effects all together. Only when an associated animation's play state become running (e.g., because a paused animation is played by a script), the UA then restart periodically updating keyframe effects. I wonder if this is how UAs will really implement it? After all, if all animations are currently paused (and only play when user clicks a button for example), keep periodically updating keyframe effects to reapply the same css properties or dom attributes over and over again is a waste of resource.

This is at least how the web-animations polyfill work: when no animation is in running play state, it stops calling `requestAnimationFrame`.

Could the spec be specified this way? So it's easier for everybody to correctly implement this optimization (e.g., when to stop and restart the periodical updating)?

Received on Wednesday, 15 April 2015 06:38:00 UTC