Title: [257417] trunk/Source/WebCore
Revision
257417
Author
[email protected]
Date
2020-02-26 02:21:29 -0800 (Wed, 26 Feb 2020)

Log Message

DocumentTimeline / CSSTransition objects are leaking on CNN.com
https://bugs.webkit.org/show_bug.cgi?id=208069
<rdar://problem/59680143>

Reviewed by Antoine Quint.

Break reference cycle between DocumentTimeline and WebAnimation by using WeakPtr.

* animation/AnimationTimeline.h:
* animation/DocumentTimeline.h:
* animation/WebAnimation.cpp:
(WebCore::WebAnimation::timeline const):
(WebCore::WebAnimation::setTimeline):
(WebCore::WebAnimation::setTimelineInternal):
(WebCore::WebAnimation::enqueueAnimationEvent):
(WebCore::WebAnimation::acceleratedStateDidChange):
* animation/WebAnimation.h:
(WebCore::WebAnimation::timeline const): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (257416 => 257417)


--- trunk/Source/WebCore/ChangeLog	2020-02-26 10:07:14 UTC (rev 257416)
+++ trunk/Source/WebCore/ChangeLog	2020-02-26 10:21:29 UTC (rev 257417)
@@ -1,3 +1,24 @@
+2020-02-26  Chris Dumez  <[email protected]>
+
+        DocumentTimeline / CSSTransition objects are leaking on CNN.com
+        https://bugs.webkit.org/show_bug.cgi?id=208069
+        <rdar://problem/59680143>
+
+        Reviewed by Antoine Quint.
+
+        Break reference cycle between DocumentTimeline and WebAnimation by using WeakPtr.
+
+        * animation/AnimationTimeline.h:
+        * animation/DocumentTimeline.h:
+        * animation/WebAnimation.cpp:
+        (WebCore::WebAnimation::timeline const):
+        (WebCore::WebAnimation::setTimeline):
+        (WebCore::WebAnimation::setTimelineInternal):
+        (WebCore::WebAnimation::enqueueAnimationEvent):
+        (WebCore::WebAnimation::acceleratedStateDidChange):
+        * animation/WebAnimation.h:
+        (WebCore::WebAnimation::timeline const): Deleted.
+
 2020-02-26  Adrian Perez de Castro  <[email protected]>
 
         Unreviewed build fix for non-unified builds.

Modified: trunk/Source/WebCore/animation/AnimationTimeline.h (257416 => 257417)


--- trunk/Source/WebCore/animation/AnimationTimeline.h	2020-02-26 10:07:14 UTC (rev 257416)
+++ trunk/Source/WebCore/animation/AnimationTimeline.h	2020-02-26 10:21:29 UTC (rev 257417)
@@ -46,7 +46,7 @@
 class DeclarativeAnimation;
 class Element;
 
-class AnimationTimeline : public RefCounted<AnimationTimeline> {
+class AnimationTimeline : public RefCounted<AnimationTimeline>, public CanMakeWeakPtr<AnimationTimeline> {
 public:
     virtual bool isDocumentTimeline() const { return false; }
 

Modified: trunk/Source/WebCore/animation/DocumentTimeline.h (257416 => 257417)


--- trunk/Source/WebCore/animation/DocumentTimeline.h	2020-02-26 10:07:14 UTC (rev 257416)
+++ trunk/Source/WebCore/animation/DocumentTimeline.h	2020-02-26 10:21:29 UTC (rev 257417)
@@ -38,7 +38,7 @@
 class AnimationEventBase;
 class RenderElement;
 
-class DocumentTimeline final : public AnimationTimeline, public CanMakeWeakPtr<DocumentTimeline>
+class DocumentTimeline final : public AnimationTimeline
 {
 public:
     static Ref<DocumentTimeline> create(Document&);

Modified: trunk/Source/WebCore/animation/WebAnimation.cpp (257416 => 257417)


--- trunk/Source/WebCore/animation/WebAnimation.cpp	2020-02-26 10:07:14 UTC (rev 257416)
+++ trunk/Source/WebCore/animation/WebAnimation.cpp	2020-02-26 10:21:29 UTC (rev 257417)
@@ -202,6 +202,11 @@
     invalidateEffect();
 }
 
+AnimationTimeline* WebAnimation::timeline() const
+{
+    return m_timeline.get();
+}
+
 void WebAnimation::setEffectInternal(RefPtr<AnimationEffect>&& newEffect, bool doNotRemoveFromTimeline)
 {
     if (m_effect == newEffect)
@@ -240,7 +245,7 @@
     // https://drafts.csswg.org/web-animations-1/#setting-the-timeline
 
     // 2. If new timeline is the same object as old timeline, abort this procedure.
-    if (timeline == m_timeline)
+    if (timeline == m_timeline.get())
         return;
 
     // 4. If the animation start time of animation is resolved, make animation's hold time unresolved.
@@ -265,7 +270,7 @@
     auto protectedThis = makeRef(*this);
     setTimelineInternal(WTFMove(timeline));
 
-    setSuspended(is<DocumentTimeline>(m_timeline) && downcast<DocumentTimeline>(*m_timeline).animationsAreSuspended());
+    setSuspended(is<DocumentTimeline>(m_timeline.get()) && downcast<DocumentTimeline>(*m_timeline).animationsAreSuspended());
 
     // 5. Run the procedure to update an animation's finished state for animation with the did seek flag set to false,
     // and the synchronously notify flag set to false.
@@ -276,13 +281,13 @@
 
 void WebAnimation::setTimelineInternal(RefPtr<AnimationTimeline>&& timeline)
 {
-    if (m_timeline == timeline)
+    if (m_timeline.get() == timeline)
         return;
 
     if (m_timeline)
         m_timeline->removeAnimation(*this);
 
-    m_timeline = WTFMove(timeline);
+    m_timeline = makeWeakPtr(timeline.get());
 
     if (m_effect)
         m_effect->animationTimelineDidChange(m_timeline.get());
@@ -690,7 +695,7 @@
 
 void WebAnimation::enqueueAnimationEvent(Ref<AnimationEventBase>&& event)
 {
-    if (is<DocumentTimeline>(m_timeline)) {
+    if (is<DocumentTimeline>(m_timeline.get())) {
         // If animation has a document for timing, then append event to its document for timing's pending animation event queue along
         // with its target, animation. If animation is associated with an active timeline that defines a procedure to convert timeline times
         // to origin-relative time, let the scheduled event time be the result of applying that procedure to timeline time. Otherwise, the
@@ -1245,7 +1250,7 @@
 
 void WebAnimation::acceleratedStateDidChange()
 {
-    if (is<DocumentTimeline>(m_timeline))
+    if (is<DocumentTimeline>(m_timeline.get()))
         downcast<DocumentTimeline>(*m_timeline).animationAcceleratedRunningStateDidChange(*this);
 }
 

Modified: trunk/Source/WebCore/animation/WebAnimation.h (257416 => 257417)


--- trunk/Source/WebCore/animation/WebAnimation.h	2020-02-26 10:07:14 UTC (rev 257416)
+++ trunk/Source/WebCore/animation/WebAnimation.h	2020-02-26 10:21:29 UTC (rev 257417)
@@ -69,7 +69,7 @@
 
     AnimationEffect* effect() const { return m_effect.get(); }
     void setEffect(RefPtr<AnimationEffect>&&);
-    AnimationTimeline* timeline() const { return m_timeline.get(); }
+    AnimationTimeline* timeline() const;
     virtual void setTimeline(RefPtr<AnimationTimeline>&&);
 
     Optional<Seconds> currentTime() const;
@@ -187,7 +187,7 @@
     void applyPendingPlaybackRate();
 
     RefPtr<AnimationEffect> m_effect;
-    RefPtr<AnimationTimeline> m_timeline;
+    WeakPtr<AnimationTimeline> m_timeline;
     UniqueRef<ReadyPromise> m_readyPromise;
     UniqueRef<FinishedPromise> m_finishedPromise;
     Markable<Seconds, Seconds::MarkableTraits> m_previousCurrentTime;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to