Title: [254951] trunk/Source/WebCore
Revision
254951
Author
[email protected]
Date
2020-01-22 16:20:24 -0800 (Wed, 22 Jan 2020)

Log Message

Make a Ref to WindowEventLoop when the timer to run tasks fires
https://bugs.webkit.org/show_bug.cgi?id=206568

Reviewed by Antti Koivisto.

Keep WindowEventLoop alive explicitly while invoking EventLoop::run.

* dom/WindowEventLoop.cpp:
(WebCore::WindowEventLoop::WindowEventLoop):
(WebCore::WindowEventLoop::didReachTimeToRun):
* dom/WindowEventLoop.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (254950 => 254951)


--- trunk/Source/WebCore/ChangeLog	2020-01-22 23:48:29 UTC (rev 254950)
+++ trunk/Source/WebCore/ChangeLog	2020-01-23 00:20:24 UTC (rev 254951)
@@ -1,3 +1,17 @@
+2020-01-21  Ryosuke Niwa  <[email protected]>
+
+        Make a Ref to WindowEventLoop when the timer to run tasks fires
+        https://bugs.webkit.org/show_bug.cgi?id=206568
+
+        Reviewed by Antti Koivisto.
+
+        Keep WindowEventLoop alive explicitly while invoking EventLoop::run.
+
+        * dom/WindowEventLoop.cpp:
+        (WebCore::WindowEventLoop::WindowEventLoop):
+        (WebCore::WindowEventLoop::didReachTimeToRun):
+        * dom/WindowEventLoop.h:
+
 2020-01-22  Brady Eidson  <[email protected]>
 
         REGRESSION (r253519): [WKWebView evaluateJavaScript:completionHandler:] gives a non-nil, non-Error result even when _javascript_ cannot be evaluated

Modified: trunk/Source/WebCore/dom/WindowEventLoop.cpp (254950 => 254951)


--- trunk/Source/WebCore/dom/WindowEventLoop.cpp	2020-01-22 23:48:29 UTC (rev 254950)
+++ trunk/Source/WebCore/dom/WindowEventLoop.cpp	2020-01-23 00:20:24 UTC (rev 254951)
@@ -82,7 +82,7 @@
 
 inline WindowEventLoop::WindowEventLoop(const String& agentClusterKey)
     : m_agentClusterKey(agentClusterKey)
-    , m_timer(*this, &WindowEventLoop::run)
+    , m_timer(*this, &WindowEventLoop::didReachTimeToRun)
     , m_perpetualTaskGroupForSimilarOriginWindowAgents(*this)
 {
 }
@@ -112,6 +112,12 @@
     return *m_microtaskQueue;
 }
 
+void WindowEventLoop::didReachTimeToRun()
+{
+    auto protectedThis = makeRef(*this); // Executing tasks may remove the last reference to this WindowEventLoop.
+    run();
+}
+
 void WindowEventLoop::queueMutationObserverCompoundMicrotask()
 {
     if (m_mutationObserverCompoundMicrotaskQueuedFlag)

Modified: trunk/Source/WebCore/dom/WindowEventLoop.h (254950 => 254951)


--- trunk/Source/WebCore/dom/WindowEventLoop.h	2020-01-22 23:48:29 UTC (rev 254950)
+++ trunk/Source/WebCore/dom/WindowEventLoop.h	2020-01-23 00:20:24 UTC (rev 254951)
@@ -61,6 +61,8 @@
     bool isContextThread() const final;
     MicrotaskQueue& microtaskQueue() final;
 
+    void didReachTimeToRun();
+
     String m_agentClusterKey;
     Timer m_timer;
     std::unique_ptr<MicrotaskQueue> m_microtaskQueue;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to