Bug 183161 - [Web Animations] Correct implementation of pending tasks and promises
Summary: [Web Animations] Correct implementation of pending tasks and promises
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Antoine Quint
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-02-27 05:09 PST by Antoine Quint
Modified: 2018-02-27 13:06 PST (History)
4 users (show)

See Also:


Attachments
Patch (39.82 KB, patch)
2018-02-27 05:25 PST, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch (39.79 KB, patch)
2018-02-27 11:45 PST, Antoine Quint
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antoine Quint 2018-02-27 05:09:05 PST
[Web Animations] Correct implementation of pending tasks and promises
Comment 1 Antoine Quint 2018-02-27 05:25:06 PST
Created attachment 334685 [details]
Patch
Comment 2 Dean Jackson 2018-02-27 11:24:05 PST
Comment on attachment 334685 [details]
Patch

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

> Source/WebCore/animation/WebAnimation.cpp:942
> +                document->postTask([this] (auto&) {
> +                    if (hasPendingPauseTask() && m_timeline)
> +                        runPendingPauseTask();
> +                });

I don't understand the build errors here, sorry. You could try [protectedThis = makeRef(*this)] and then protectedThis->hasPendingPauseTask()

> Source/WebCore/animation/WebAnimation.h:149
> +    UniqueRef<ReadyPromise> m_readyPromise;
> +    UniqueRef<FinishedPromise> m_finishedPromise;

I didn't really understand the message from the changelog about this. Why store refs, instead of the promises directly? Then instead of clear(), you'd call clear and assign a new instance.
Comment 3 Chris Dumez 2018-02-27 11:28:47 PST
Comment on attachment 334685 [details]
Patch

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

> Source/WebCore/animation/WebAnimation.cpp:952
> +                    if (hasPendingPlayTask() && m_timeline)

Use this->hasPendingPlayTask() to make gcc happy.
Comment 4 Chris Dumez 2018-02-27 11:36:53 PST
Comment on attachment 334685 [details]
Patch

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

> Source/WebCore/animation/WebAnimation.cpp:939
> +                document->postTask([this] (auto&) {

What guarantees |this| is still alive when the task is executed asynchronously? We usually capture protectedThis = makeRef(*this) to avoid this problem.

>> Source/WebCore/animation/WebAnimation.cpp:942
>> +                });
> 
> I don't understand the build errors here, sorry. You could try [protectedThis = makeRef(*this)] and then protectedThis->hasPendingPauseTask()

gcc just needs some explicit this-> to make it happy.

> Source/WebCore/animation/WebAnimation.cpp:949
> +        if (is<DocumentTimeline>(m_timeline)) {

This could be merged with the previous condition (is<>() does a null check when passed in a pointer type.
if (hasPendingPlayTask() && is<DocumentTimeline>(m_timeline))

> Source/WebCore/animation/WebAnimation.cpp:951
> +                document->postTask([this] (auto&) {

Ditto about lifetime.
Comment 5 Antoine Quint 2018-02-27 11:45:57 PST
Created attachment 334696 [details]
Patch
Comment 6 Antoine Quint 2018-02-27 13:05:12 PST
Committed r229069: <https://trac.webkit.org/changeset/229069>
Comment 7 Radar WebKit Bug Importer 2018-02-27 13:06:27 PST
<rdar://problem/37953727>