Bug 212103 - [Web Animations] Animation engine should not wake up every tick for steps timing functions
Summary: [Web Animations] Animation engine should not wake up every tick for steps tim...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Animations (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Antoine Quint
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-05-19 13:03 PDT by Antoine Quint
Modified: 2020-05-20 09:29 PDT (History)
10 users (show)

See Also:


Attachments
Patch (18.77 KB, patch)
2020-05-19 13:12 PDT, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch (22.25 KB, patch)
2020-05-20 03:45 PDT, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch (24.63 KB, patch)
2020-05-20 03:49 PDT, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch (27.99 KB, patch)
2020-05-20 06:59 PDT, Antoine Quint
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antoine Quint 2020-05-19 13:03:19 PDT
[Web Animations] Animation engine should not wake up every tick for steps timing functions
Comment 1 Antoine Quint 2020-05-19 13:12:08 PDT
Created attachment 399764 [details]
Patch
Comment 2 Antoine Quint 2020-05-19 13:12:13 PDT
<rdar://problem/62737868>
Comment 3 Simon Fraser (smfr) 2020-05-19 13:26:25 PDT
Comment on attachment 399764 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=399764&action=review

> Source/WebCore/animation/AnimationEffect.cpp:547
> +    if (!is<StepsTimingFunction>(m_timingFunction))
> +        return WTF::nullopt;

Does this get called for animations whose keyframes all have the same value? Or did we optimize those out earlier?

> Source/WebCore/animation/KeyframeEffect.cpp:1825
> +        if (intervalEndProgress <= iterationProgress)
> +            continue;
> +
> +        if (!i)
> +            break;

This is pretty confusing. The !i makes it always break after i=0, but you continue earlier. Easier to grok if it's flipped around somehow.
Comment 4 Antoine Quint 2020-05-19 13:48:00 PDT
(In reply to Simon Fraser (smfr) from comment #3)
> Comment on attachment 399764 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=399764&action=review
> 
> > Source/WebCore/animation/AnimationEffect.cpp:547
> > +    if (!is<StepsTimingFunction>(m_timingFunction))
> > +        return WTF::nullopt;
> 
> Does this get called for animations whose keyframes all have the same value?
> Or did we optimize those out earlier?

We don’t optimize this case in any way for now. So this would get called for any animation.

> > Source/WebCore/animation/KeyframeEffect.cpp:1825
> > +        if (intervalEndProgress <= iterationProgress)
> > +            continue;
> > +
> > +        if (!i)
> > +            break;
> 
> This is pretty confusing. The !i makes it always break after i=0, but you
> continue earlier. Easier to grok if it's flipped around somehow.

The order matters here. We just want to be sure that we don’t deal with an implicit 0% keyframe since we wouldn’t have a blending keyframe for that and would otherwise crash trying to access its timing function.
Comment 5 Antoine Quint 2020-05-20 03:45:53 PDT
Created attachment 399827 [details]
Patch
Comment 6 Antoine Quint 2020-05-20 03:49:03 PDT
Created attachment 399828 [details]
Patch
Comment 7 Antoine Quint 2020-05-20 06:59:14 PDT
Created attachment 399835 [details]
Patch
Comment 8 Simon Fraser (smfr) 2020-05-20 08:15:30 PDT
Comment on attachment 399835 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=399835&action=review

> Source/WebCore/animation/KeyframeEffect.cpp:1476
> +    if (index < 0)
> +        return nullptr;

size_t is unsigned, this can never happen.

> Source/WebCore/animation/KeyframeEffect.cpp:1837
> +Optional<double> KeyframeEffect::progressUntilNextStep(double iterationProgress) const

"progress until" is a bit ambiguous here. Maybe "progress at next step"?
Comment 9 Antoine Quint 2020-05-20 09:24:31 PDT
(In reply to Simon Fraser (smfr) from comment #8)
> Comment on attachment 399835 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=399835&action=review
> 
> > Source/WebCore/animation/KeyframeEffect.cpp:1476
> > +    if (index < 0)
> > +        return nullptr;
> 
> size_t is unsigned, this can never happen.

Will remove in commit.

> > Source/WebCore/animation/KeyframeEffect.cpp:1837
> > +Optional<double> KeyframeEffect::progressUntilNextStep(double iterationProgress) const
> 
> "progress until" is a bit ambiguous here. Maybe "progress at next step"?

"progress at next step" would not be correct, what we want to know is "how much progress until the next step". I think within the context of determining the amount of time before the next step, which is the only scenario in which this method is used, this is clear enough.
Comment 10 Antoine Quint 2020-05-20 09:26:25 PDT
Committed r261926: <https://trac.webkit.org/changeset/261926>
Comment 11 Antoine Quint 2020-05-20 09:29:57 PDT
Committed r261927: <https://trac.webkit.org/changeset/261927>