Skip to content

[web-animations] Allow adjacent filling animations to be coalesced #3210

Closed
@birtles

Description

@birtles

Closely related:

Using the Web Animations API authors can easily generate animations in an unbounded fashion. Unless a means is provided to UAs to discard or compact these animations, this will result in a memory leak.

For example:

elem.addEventListener('mousemove', evt => {
  circle.animate(
    { transform: `translate(${evt.clientX}, ${evt.clientY})` },
    { duration: 500, fill: 'forwards' }
  );
});

Comparing to other animation techniques:

  • CSS transitions do not suffer this problem since there can only be one animation per property at any time.
  • SMIL does not suffer this problem since each <animate>-type element only has one active interval at a time so that number of simultaneous animations is bounded by the number of <animate>-type elements (and if an author is producing <animate> elements in an unbounded fashion they hopefully won't be surprised to learn that they're leaking memory!).
  • CSS animations technically suffers this problem except that it is more obvious to authors that they are producing a memory leak since they must explicitly append to the list of animations each time. By contrast, there is nothing in the above code to suggest to an author that they are creating a memory leak.

One reason past animations must be retained is due to the way the getAnimations() API is currently defined. Issue #2054 will define a means to avoid having getAnimations() return all such animations.

The other reason past animations must be retained is to produce the correct result when additive animations or animations with implicit keyframes are involved. As a result, even once getAnimations() is fixed, there are many circumstances where UAs cannot discard or compact past animations, thereby producing a memory leak.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions