Changeset 251742 in webkit
- Timestamp:
- Oct 29, 2019 4:07:16 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r251741 r251742 1 2019-10-29 Antoine Quint <graouts@apple.com> 2 3 WebAnimation should never prevent entering the back/forward cache 4 https://bugs.webkit.org/show_bug.cgi?id=203088 5 <rdar://problem/56374249> 6 7 Reviewed by Antti Koivisto. 8 9 Add a new test that checks that an Animation that would run past a page's navigation is correctly suspended 10 and resumed as it enters and leaves the back/forward cache. 11 12 * webanimations/animation-page-cache-expected.txt: Added. 13 * webanimations/animation-page-cache.html: Added. 14 1 15 2019-10-29 Megan Gardner <megan_gardner@apple.com> 2 16 -
trunk/LayoutTests/webanimations/leak-document-with-web-animation-expected.txt
r233583 r251742 5 5 6 6 The iframe has finished loading. 7 The iframe has been destroyed. 8 PASS internals.numberOfLiveDocuments() is numberOfLiveDocumentsAfterIframeLoaded - 1 9 7 PASS The document was destroyed 10 8 PASS successfullyParsed is true 11 9 -
trunk/LayoutTests/webanimations/leak-document-with-web-animation.html
r233583 r251742 2 2 <html> 3 3 <body onload="runTest()"> 4 <script src="../resources/js-test -pre.js"></script>4 <script src="../resources/js-test.js"></script> 5 5 <script> 6 6 description("This test asserts that Document doesn't leak when a Web Animation is created."); … … 8 8 if (window.internals) 9 9 jsTestIsAsync = true; 10 11 gc();12 13 var numberOfLiveDocumentsAfterIframeLoaded = 0;14 10 15 11 function runTest() { … … 23 19 return true; 24 20 25 numberOfLiveDocumentsAfterIframeLoaded = internals.numberOfLiveDocuments();21 documentIdentifier = internals.documentIdentifier(frame.contentDocument); 26 22 debug("The iframe has finished loading."); 27 23 … … 29 25 frame = null; 30 26 31 setTimeout(() => { 27 gc(); 28 timeout = 0; 29 handle = setInterval(() => { 30 if (!internals.isDocumentAlive(documentIdentifier)) { 31 clearInterval(handle); 32 testPassed("The document was destroyed"); 33 finishJSTest(); 34 return; 35 } 36 timeout++; 37 if (timeout == 500) { 38 clearInterval(handle); 39 testFailed("The document was leaked"); 40 finishJSTest(); 41 return; 42 } 32 43 gc(); 33 setTimeout(function () { 34 debug("The iframe has been destroyed."); 35 shouldBe("internals.numberOfLiveDocuments()", "numberOfLiveDocumentsAfterIframeLoaded - 1"); 36 debug(""); 37 finishJSTest(); 38 }); 39 }); 44 }, 10); 40 45 } 41 46 … … 44 49 45 50 </script> 46 <script src="../resources/js-test-post.js"></script>47 51 </body> 48 52 </html> -
trunk/Source/WebCore/ChangeLog
r251737 r251742 1 2019-10-29 Antoine Quint <graouts@apple.com> 2 3 WebAnimation should never prevent entering the back/forward cache 4 https://bugs.webkit.org/show_bug.cgi?id=203088 5 <rdar://problem/56374249> 6 7 Reviewed by Antti Koivisto. 8 9 Test: webanimations/animation-page-cache.html 10 11 We remove the Web Animation override of the deprecated method ActiveDOMObject::shouldPreventEnteringBackForwardCache_DEPRECATED() 12 and instead ensure event dispatch is suspended along with the WebAnimation object through the adoption of a SuspendableTaskQueue. 13 14 We also ensure an animation correctly suspends itself when ActiveDOMObject::suspend() and ActiveDOMObject::resume() are called. 15 Implementing these methods showed that we have some placeholders in DeclarativeAnimation that were not necessary, so we remove those. 16 17 Finally, we no longer need to track the stopped state since the SuspendableTaskQueue will close itself when ActiveDOMObject::stop() 18 is called. 19 20 * animation/DeclarativeAnimation.cpp: 21 (WebCore::DeclarativeAnimation::stop): Deleted. 22 (WebCore::DeclarativeAnimation::suspend): Deleted. 23 (WebCore::DeclarativeAnimation::resume): Deleted. 24 * animation/DeclarativeAnimation.h: 25 * animation/WebAnimation.cpp: 26 (WebCore::WebAnimation::WebAnimation): 27 (WebCore::WebAnimation::enqueueAnimationPlaybackEvent): 28 (WebCore::WebAnimation::suspend): 29 (WebCore::WebAnimation::resume): 30 (WebCore::WebAnimation::stop): 31 (WebCore::WebAnimation::hasPendingActivity): 32 (WebCore::WebAnimation::shouldPreventEnteringBackForwardCache_DEPRECATED const): Deleted. 33 * animation/WebAnimation.h: 34 1 35 2019-10-07 Jer Noble <jer.noble@apple.com> 2 36 -
trunk/Source/WebCore/animation/DeclarativeAnimation.cpp
r250617 r251742 347 347 } 348 348 349 void DeclarativeAnimation::stop()350 {351 WebAnimation::stop();352 }353 354 void DeclarativeAnimation::suspend(ReasonForSuspension reason)355 {356 WebAnimation::suspend(reason);357 }358 359 void DeclarativeAnimation::resume()360 {361 WebAnimation::resume();362 }363 364 349 } // namespace WebCore -
trunk/Source/WebCore/animation/DeclarativeAnimation.h
r250617 r251742 82 82 void remove() final; 83 83 84 // ActiveDOMObject.85 void suspend(ReasonForSuspension) final;86 void resume() final;87 void stop() final;88 89 84 bool m_wasPending { false }; 90 85 AnimationEffectPhase m_previousPhase { AnimationEffectPhase::Idle }; -
trunk/Source/WebCore/animation/WebAnimation.cpp
r251244 r251742 68 68 , m_readyPromise(makeUniqueRef<ReadyPromise>(*this, &WebAnimation::readyPromiseResolve)) 69 69 , m_finishedPromise(makeUniqueRef<FinishedPromise>(*this, &WebAnimation::finishedPromiseResolve)) 70 , m_taskQueue(SuspendableTaskQueue::create(document)) 70 71 { 71 72 m_readyPromise->resolve(*this); … … 614 615 } else { 615 616 // Otherwise, queue a task to dispatch event at animation. The task source for this task is the DOM manipulation task source. 616 callOnMainThread([this, pendingActivity = makePendingActivity(*this), event = WTFMove(event)]() { 617 if (!m_isStopped) 618 this->dispatchEvent(event); 617 m_taskQueue->enqueueTask([this, event = WTFMove(event)] { 618 dispatchEvent(event); 619 619 }); 620 620 } … … 1158 1158 } 1159 1159 1160 // FIXME: This should never prevent entering the back/forward cache. 1161 bool WebAnimation::shouldPreventEnteringBackForwardCache_DEPRECATED() const 1162 { 1163 // Use the base class's implementation of hasPendingActivity() since we wouldn't want the custom implementation 1164 // in this class designed to keep JS wrappers alive to interfere with the ability for a page using animations 1165 // to enter the back/forward cache. 1166 return ActiveDOMObject::hasPendingActivity(); 1160 void WebAnimation::suspend(ReasonForSuspension) 1161 { 1162 setSuspended(true); 1163 } 1164 1165 void WebAnimation::resume() 1166 { 1167 setSuspended(false); 1167 1168 } 1168 1169 1169 1170 void WebAnimation::stop() 1170 1171 { 1172 m_taskQueue->cancelAllTasks(); 1171 1173 ActiveDOMObject::stop(); 1172 m_isStopped = true;1173 1174 removeAllEventListeners(); 1174 1175 } … … 1177 1178 { 1178 1179 // Keep the JS wrapper alive if the animation is considered relevant or could become relevant again by virtue of having a timeline. 1179 return m_timeline || m_isRelevant || ActiveDOMObject::hasPendingActivity();1180 return m_timeline || m_isRelevant || m_taskQueue->hasPendingTasks() || ActiveDOMObject::hasPendingActivity(); 1180 1181 } 1181 1182 -
trunk/Source/WebCore/animation/WebAnimation.h
r251244 r251742 30 30 #include "ExceptionOr.h" 31 31 #include "IDLTypes.h" 32 #include "SuspendableTaskQueue.h" 32 33 #include "WebAnimationUtilities.h" 33 34 #include <wtf/Markable.h> … … 140 141 protected: 141 142 explicit WebAnimation(Document&); 142 143 void stop() override;144 143 145 144 private: … … 177 176 UniqueRef<ReadyPromise> m_readyPromise; 178 177 UniqueRef<FinishedPromise> m_finishedPromise; 178 UniqueRef<SuspendableTaskQueue> m_taskQueue; 179 179 Markable<Seconds, Seconds::MarkableTraits> m_previousCurrentTime; 180 180 Markable<Seconds, Seconds::MarkableTraits> m_startTime; … … 186 186 int m_suspendCount { 0 }; 187 187 188 bool m_isStopped { false };189 188 bool m_isSuspended { false }; 190 189 bool m_finishNotificationStepsMicrotaskPending; … … 198 197 // ActiveDOMObject. 199 198 const char* activeDOMObjectName() const final; 200 bool shouldPreventEnteringBackForwardCache_DEPRECATED() const final; 199 void suspend(ReasonForSuspension) final; 200 void resume() final; 201 void stop() final; 201 202 202 203 // EventTarget -
trunk/Source/WebCore/platform/SuspendableTaskQueue.h
r251244 r251742 59 59 bool isClosed() const { return m_isClosed; } 60 60 61 bool hasPendingTasks() const { return m_pendingTasks.isEmpty(); }61 bool hasPendingTasks() const { return !m_pendingTasks.isEmpty(); } 62 62 63 63 private:
Note: See TracChangeset
for help on using the changeset viewer.