Bug 211668

Summary: Tighten up logic in DocumentTimelinesController::updateAnimationsAndSendEvents
Product: WebKit Reporter: Darin Adler <darin>
Component: AnimationsAssignee: Darin Adler <darin>
Status: RESOLVED FIXED    
Severity: Normal CC: dino, graouts, graouts, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch
none
Patch graouts: review+

Description Darin Adler 2020-05-09 12:30:18 PDT
Tighten up logic in DocumentTimelinesController::updateAnimationsAndSendEvents
Comment 1 Darin Adler 2020-05-09 12:34:34 PDT Comment hidden (obsolete)
Comment 2 Darin Adler 2020-05-09 12:36:09 PDT Comment hidden (obsolete)
Comment 3 Darin Adler 2020-05-09 16:32:41 PDT
Created attachment 398945 [details]
Patch
Comment 4 Antoine Quint 2020-05-10 01:45:51 PDT
Comment on attachment 398945 [details]
Patch

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

r=me, but there are a couple of things you should adjust before landing based on feedback.

> Source/WebCore/animation/DocumentTimelinesController.cpp:136
> +        // 2. Within events with equal scheduled event times, sort by their composite order. FIXME: Need to do this.
> +        return lhs->timelineTime() < rhs->timelineTime();

I'm not sure about that bit. How does this work if one of those two values is WTF::nullopt?

> Source/WebCore/animation/DocumentTimelinesController.cpp:149
> +                // FIXME: Should this use WebAnimation::remove instead of Timeline::removeAnimation?

Calling `WebAnimation::remove()` is not correct here. All we want to do is remove the animation from the list of relevant animations for this timeline, but we do not want to alter its animation-to-timeline or animation-to-effect relationships, which is what `WebAnimation::remove()` would do. Indeed, there may be JS references to that animation, and we cannot alter this object.
Comment 5 Darin Adler 2020-05-10 13:52:16 PDT
Comment on attachment 398945 [details]
Patch

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

>> Source/WebCore/animation/DocumentTimelinesController.cpp:136
>> +        return lhs->timelineTime() < rhs->timelineTime();
> 
> I'm not sure about that bit. How does this work if one of those two values is WTF::nullopt?

nullopt compares as less than any non-nullopt

And that’s exactly what’s the code above was doing. Except for a bug where the code was returning “true” when both are nullopt. That‘a not really OK, but it probably did no harm in practice in the sort.

>> Source/WebCore/animation/DocumentTimelinesController.cpp:149
>> +                // FIXME: Should this use WebAnimation::remove instead of Timeline::removeAnimation?
> 
> Calling `WebAnimation::remove()` is not correct here. All we want to do is remove the animation from the list of relevant animations for this timeline, but we do not want to alter its animation-to-timeline or animation-to-effect relationships, which is what `WebAnimation::remove()` would do. Indeed, there may be JS references to that animation, and we cannot alter this object.

OK, I will not check in this FIXME.
Comment 6 Darin Adler 2020-05-10 14:22:03 PDT
Committed r261459: <https://trac.webkit.org/changeset/261459>
Comment 7 Radar WebKit Bug Importer 2020-05-10 14:23:12 PDT
<rdar://problem/63069361>