Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[scroll-animations] should an infinite duration yield an exception for effects associated with a progress-based animation? #11804

Open
graouts opened this issue Feb 28, 2025 · 2 comments
Labels

Comments

@graouts
Copy link
Contributor

graouts commented Feb 28, 2025

The WPT test scroll-animations/scroll-timelines/effect-updateTiming.html checks that setting Infinity for the duration of a keyframe effect associated with a progress-based animation throws:

// adapted for progress based animations
const gBadDurationValuesForProgressBased = [
  -1, NaN, Infinity, -Infinity, 'abc', '100'
];


for (const invalid of gBadDurationValuesForProgressBased) {
  test(t => {
    assert_throws_js(TypeError, () => {
      const anim = createScrollLinkedAnimationWithTiming(t,  { duration: invalid })
      anim.play();
    });
  }, 'Throws when setting invalid duration: '
     + (typeof invalid === 'string' ? `"${invalid}"` : invalid));
}

Web Animations Level 1 specifies duration thus:

The iteration duration, which is a real number greater than or equal to zero (including positive infinity) representing the time taken to complete a single iteration of the animation effect.

Reading through Web Animations Level 2 and Scroll-driven Animations Level 1 I cannot find any additional normative text that would indicate that Infinity is not a valid value for the duration of a progress-based animation.

Chrome throws in that scenario, so I expect it was the intention of Chromium engineers to specify this behavior.

@graouts graouts added scroll-animations-1 Current Work web-animations-2 Current Work labels Feb 28, 2025
graouts added a commit to graouts/WebKit that referenced this issue Feb 28, 2025
…t-updateTiming.html has failures

https://bugs.webkit.org/show_bug.cgi?id=284542
rdar://141356805

Reviewed by NOBODY (OOPS!).

The Web Animations Level 1 specification indicates the following for the `duration` property
of the `OptionalEffectTiming` interface [0]:

    > The iteration duration, which is a real number greater than or equal to zero
    > (including positive infinity) representing the time taken to complete a single
    > iteration of the animation effect.

Looking through the Web Animations Level 2 and Scroll-driven Animations Level 1 specifications,
there is no text anywhere that indicates that an infinite duration for a progress-based animation
would yield an exception. As such, the test expecting `Infinity` for `duration` to throw is in
error. So we're modifying the relevant test to expect this to be a valid value instead.

Assuming there may have been an intent to restrict the `duration` for progress-based animations,
the following issue [1] was filed on the Scroll-driven Animations specification.

[0] https://drafts.csswg.org/web-animations-1/#dom-effecttiming-duration
[1] w3c/csswg-drafts#11804

* LayoutTests/imported/w3c/web-platform-tests/scroll-animations/scroll-timelines/effect-updateTiming-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/scroll-animations/scroll-timelines/effect-updateTiming.html:
@graouts
Copy link
Contributor Author

graouts commented Feb 28, 2025

Cc @flackr, @andruud, @kevers-google and @bramus.

@flackr
Copy link
Contributor

flackr commented Mar 1, 2025

Right, playing an infinite duration animation in reverse throws an exception because it would result in an impossible to compute state: https://drafts.csswg.org/web-animations-1/#playing-an-animation-section.

In a similar manner, playing an infinite duration animation with a non-monotonic timeline invokes a conversion that attempts to use the end time of the animation: https://drafts.csswg.org/web-animations-2/#time-based-animation-to-a-proportional-animation.

It's a good idea to call it out explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants