Bug 211668 - Tighten up logic in DocumentTimelinesController::updateAnimationsAndSendEvents
Summary: Tighten up logic in DocumentTimelinesController::updateAnimationsAndSendEvents
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Animations (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Darin Adler
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-05-09 12:30 PDT by Darin Adler
Modified: 2020-05-10 14:23 PDT (History)
4 users (show)

See Also:


Attachments
Patch (8.62 KB, patch)
2020-05-09 12:34 PDT, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (8.62 KB, patch)
2020-05-09 12:36 PDT, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (8.48 KB, patch)
2020-05-09 16:32 PDT, Darin Adler
graouts: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>