Title: [212814] trunk
Revision
212814
Author
[email protected]
Date
2017-02-22 00:30:18 -0800 (Wed, 22 Feb 2017)

Log Message

[GTK] Test fast/events/message-port-postMessage-recursive.html times out
https://bugs.webkit.org/show_bug.cgi?id=168570

Reviewed by Michael Catanzaro.

Source/WTF:

This has recently been added and the patch is good. It's just revealing a problem with our timers. The test is
posting a message recursively, and also starts a timeout timer to finish the test. The timeout timer is never
fired for us, because WebCore timers have lower priority than the one used by postMessage. ScriptExecutionContext
uses Document::postTask, that uses scheduleOnMainThread, that uses RunLoop::dispatch(). We are not setting any
priority for the timer used by RunLoop::dispatch, so it's using the default.
Use a RunLoop::Timer to schedule tasks to the main thread instead of using RunLoop::dispatch(). This allows us
to use a different priority, that is now set to G_PRIORITY_HIGH_IDLE + 20 to match WebCore timers. But it also
avoids the double queue we had with RunLoop::dispatch(), because scheduleOnMainThread() also queues the tasks.

* wtf/glib/MainThreadGLib.cpp:
(WTF::MainThreadDispatcher::MainThreadDispatcher):
(WTF::MainThreadDispatcher::schedule):
(WTF::MainThreadDispatcher::fired):
(WTF::scheduleDispatchFunctionsOnMainThread):

LayoutTests:

* platform/gtk/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (212813 => 212814)


--- trunk/LayoutTests/ChangeLog	2017-02-22 08:04:18 UTC (rev 212813)
+++ trunk/LayoutTests/ChangeLog	2017-02-22 08:30:18 UTC (rev 212814)
@@ -1,3 +1,12 @@
+2017-02-22  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Test fast/events/message-port-postMessage-recursive.html times out
+        https://bugs.webkit.org/show_bug.cgi?id=168570
+
+        Reviewed by Michael Catanzaro.
+
+        * platform/gtk/TestExpectations:
+
 2017-02-21  Youenn Fablet  <[email protected]>
 
         [WebRTC][Mac] Activate libwebrtc

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (212813 => 212814)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2017-02-22 08:04:18 UTC (rev 212813)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2017-02-22 08:30:18 UTC (rev 212814)
@@ -1793,8 +1793,6 @@
 
 webkit.org/b/168569 http/tests/appcache/main-resource-fallback-for-network-error-crash.html [ Timeout ]
 
-webkit.org/b/168570 fast/events/message-port-postMessage-recursive.html [ Timeout ]
-
 #////////////////////////////////////////////////////////////////////////////////////////
 # End of Tests timing out
 #////////////////////////////////////////////////////////////////////////////////////////

Modified: trunk/Source/WTF/ChangeLog (212813 => 212814)


--- trunk/Source/WTF/ChangeLog	2017-02-22 08:04:18 UTC (rev 212813)
+++ trunk/Source/WTF/ChangeLog	2017-02-22 08:30:18 UTC (rev 212814)
@@ -1,3 +1,25 @@
+2017-02-22  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Test fast/events/message-port-postMessage-recursive.html times out
+        https://bugs.webkit.org/show_bug.cgi?id=168570
+
+        Reviewed by Michael Catanzaro.
+
+        This has recently been added and the patch is good. It's just revealing a problem with our timers. The test is
+        posting a message recursively, and also starts a timeout timer to finish the test. The timeout timer is never
+        fired for us, because WebCore timers have lower priority than the one used by postMessage. ScriptExecutionContext
+        uses Document::postTask, that uses scheduleOnMainThread, that uses RunLoop::dispatch(). We are not setting any
+        priority for the timer used by RunLoop::dispatch, so it's using the default.
+        Use a RunLoop::Timer to schedule tasks to the main thread instead of using RunLoop::dispatch(). This allows us
+        to use a different priority, that is now set to G_PRIORITY_HIGH_IDLE + 20 to match WebCore timers. But it also
+        avoids the double queue we had with RunLoop::dispatch(), because scheduleOnMainThread() also queues the tasks.
+
+        * wtf/glib/MainThreadGLib.cpp:
+        (WTF::MainThreadDispatcher::MainThreadDispatcher):
+        (WTF::MainThreadDispatcher::schedule):
+        (WTF::MainThreadDispatcher::fired):
+        (WTF::scheduleDispatchFunctionsOnMainThread):
+
 2017-02-21  Youenn Fablet  <[email protected]>
 
         [WebRTC][Mac] Activate libwebrtc

Modified: trunk/Source/WTF/wtf/glib/MainThreadGLib.cpp (212813 => 212814)


--- trunk/Source/WTF/wtf/glib/MainThreadGLib.cpp	2017-02-22 08:04:18 UTC (rev 212813)
+++ trunk/Source/WTF/wtf/glib/MainThreadGLib.cpp	2017-02-22 08:30:18 UTC (rev 212814)
@@ -30,10 +30,33 @@
 #include "config.h"
 #include "MainThread.h"
 
+#include <glib.h>
 #include <wtf/RunLoop.h>
 
 namespace WTF {
 
+class MainThreadDispatcher {
+public:
+    MainThreadDispatcher()
+        : m_timer(RunLoop::main(), this, &MainThreadDispatcher::fired)
+    {
+        m_timer.setPriority(G_PRIORITY_HIGH_IDLE + 20);
+    }
+
+    void schedule()
+    {
+        m_timer.startOneShot(0);
+    }
+
+private:
+    void fired()
+    {
+        dispatchFunctionsFromMainThread();
+    }
+
+    RunLoop::Timer<MainThreadDispatcher> m_timer;
+};
+
 void initializeMainThreadPlatform()
 {
 }
@@ -40,7 +63,10 @@
 
 void scheduleDispatchFunctionsOnMainThread()
 {
-    RunLoop::main().dispatch(std::function<void()>(dispatchFunctionsFromMainThread));
+    // Use a RunLoop::Timer instead of RunLoop::dispatch() to be able to use a different priority and
+    // avoid the double queue because dispatchOnMainThread also queues the functions.
+    static MainThreadDispatcher dispatcher;
+    dispatcher.schedule();
 }
 
 } // namespace WTF
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to