Created attachment 33876 [details] Testcase If a page creates keyframes rules on the fly with JS, but relies on the animation-name already existing on the element, then the animation does not start. See testcase.
This is the same as rdar://problem/6276692
It looks like this bug is probably in CompositeAnimation::updateKeyframeAnimations. We take the "animations of target style and current style are equal" branch and don't look up if the underlying keyframes have changed. We shouldn't change an animation that has already started in the case that we're redefining an @keyframes rule, but we should start an animation if none is running. Spec says: "The values used for the keyframes and animation properties are snapshotted at the time the animation starts. Changing them during the execution of the animation has no effect. Note also that changing the value of ‘animation-name’ does not necessarily restart an animation (e.g., if a list of animations are applied and one is removed from the list, only that animation will stop; The other animations will continue). In order to restart an animation, it must be removed then reapplied." I guess if an animation already finished (is postActive) then we should start it again for a new @keyframes definition.
In order to do this correctly in CompositeAnimation, We'd need to know if a @keyframes rule is new (hasn't been seen by this CompositeAnimation instance before). Is there any existing mechanism to tell if a rule is "new" for the current recalc?
STP165 is matching with Chrome Canary 113 and Firefox Nightly 113, where the attached test case animate on page load but only difference is that rather than 5 times, it animates only 3 times. Is it something still to fix?
With STP 165, I see the square animate 5 times. Could you share more about your configuration? I'm surprised you see otherwise.
I am counting one side as '1' and not backward. It could be issue. Let me attach video shortly.
Created attachment 465526 [details] STP165 video recording on macOS 13.2.1 Video Recording attached of what I am seeing. I counted '3' from ---> this direction only but not <---- but if I count those then I think they are '5'.
Yes, that is the behavior I see across STP 165, Firefox and Chrome. I'll let you confirm this on your own machine, but I believe this is behaving correctly.
(In reply to Antoine Quint from comment #8) > Yes, that is the behavior I see across STP 165, Firefox and Chrome. I'll let > you confirm this on your own machine, but I believe this is behaving > correctly. Do we need to keep it open, or we can mark it as "RESOLVED CONFIGURATION CHANGED"?