Title: [195667] releases/WebKitGTK/webkit-2.10/Source/WebCore
Revision
195667
Author
[email protected]
Date
2016-01-27 05:33:55 -0800 (Wed, 27 Jan 2016)

Log Message

Merge r195537 - REGRESSION(r192773): [GTK] maps.google.com unresponsive/stalls since r192773
https://bugs.webkit.org/show_bug.cgi?id=153194

Reviewed by Michael Catanzaro.

In r192773 we implemented the _javascript_Core garbage collector
timers for the GTK+ port. Those timers schedule sources in the
current thread default main context, but JS web worker threads
implementation doesn't use WTF::RunLoop, but its own WorkerRunLoop
class that doesn't create a GMainContext for the new thread. This
means that for web sites using workers, we are now doing garbage
collection of worker VMs in the main thread which ends up in a
deadlock at some point. We need to ensure that worker threads
create a GMainContext and push it as the default one for the
thread before the WorkerGlobalScope is created. This way when the
worker Heap is created, the GC timers use the right context to
schedule their sources. And then we need to check if there are
sources pending in the thread main context on every worker run
loop iteration.

* workers/WorkerRunLoop.cpp:
(WebCore::WorkerRunLoop::runInMode):
* workers/WorkerThread.cpp:
(WebCore::WorkerThread::workerThread):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog (195666 => 195667)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2016-01-27 13:31:39 UTC (rev 195666)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2016-01-27 13:33:55 UTC (rev 195667)
@@ -1,3 +1,30 @@
+2016-01-25  Carlos Garcia Campos  <[email protected]>
+
+        REGRESSION(r192773): [GTK] maps.google.com unresponsive/stalls since r192773
+        https://bugs.webkit.org/show_bug.cgi?id=153194
+
+        Reviewed by Michael Catanzaro.
+
+        In r192773 we implemented the _javascript_Core garbage collector
+        timers for the GTK+ port. Those timers schedule sources in the
+        current thread default main context, but JS web worker threads
+        implementation doesn't use WTF::RunLoop, but its own WorkerRunLoop
+        class that doesn't create a GMainContext for the new thread. This
+        means that for web sites using workers, we are now doing garbage
+        collection of worker VMs in the main thread which ends up in a
+        deadlock at some point. We need to ensure that worker threads
+        create a GMainContext and push it as the default one for the
+        thread before the WorkerGlobalScope is created. This way when the
+        worker Heap is created, the GC timers use the right context to
+        schedule their sources. And then we need to check if there are
+        sources pending in the thread main context on every worker run
+        loop iteration.
+
+        * workers/WorkerRunLoop.cpp:
+        (WebCore::WorkerRunLoop::runInMode):
+        * workers/WorkerThread.cpp:
+        (WebCore::WorkerThread::workerThread):
+
 2016-01-23  Wonchul Lee  <[email protected]>
 
         [GTK] Fix media controls displaying without controls attribute

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/workers/WorkerRunLoop.cpp (195666 => 195667)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/workers/WorkerRunLoop.cpp	2016-01-27 13:31:39 UTC (rev 195666)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/workers/WorkerRunLoop.cpp	2016-01-27 13:33:55 UTC (rev 195667)
@@ -39,6 +39,10 @@
 #include "WorkerThread.h"
 #include <wtf/CurrentTime.h>
 
+#if PLATFORM(GTK)
+#include <glib.h>
+#endif
+
 namespace WebCore {
 
 class WorkerSharedTimer : public SharedTimer {
@@ -148,6 +152,12 @@
     ASSERT(context);
     ASSERT(context->thread().threadID() == currentThread());
 
+#if PLATFORM(GTK)
+    GMainContext* mainContext = g_main_context_get_thread_default();
+    if (g_main_context_pending(mainContext))
+        g_main_context_iteration(mainContext, FALSE);
+#endif
+
     double deadline = MessageQueue<Task>::infiniteTime();
 
 #if USE(CF)

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/workers/WorkerThread.cpp (195666 => 195667)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/workers/WorkerThread.cpp	2016-01-27 13:31:39 UTC (rev 195666)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/workers/WorkerThread.cpp	2016-01-27 13:33:55 UTC (rev 195667)
@@ -45,6 +45,10 @@
 #include "WebCoreThread.h"
 #endif
 
+#if PLATFORM(GTK)
+#include <wtf/glib/GRefPtr.h>
+#endif
+
 namespace WebCore {
 
 static StaticLock threadSetMutex;
@@ -135,6 +139,11 @@
     FloatingPointEnvironment::singleton().propagateMainThreadEnvironment();
 #endif
 
+#if PLATFORM(GTK)
+    GRefPtr<GMainContext> mainContext = adoptGRef(g_main_context_new());
+    g_main_context_push_thread_default(mainContext.get());
+#endif
+
     {
         LockHolder lock(m_threadCreationMutex);
         m_workerGlobalScope = createWorkerGlobalScope(m_startupData->m_scriptURL, m_startupData->m_userAgent, m_startupData->m_contentSecurityPolicy, m_startupData->m_contentSecurityPolicyType, m_startupData->m_topOrigin.release());
@@ -156,6 +165,10 @@
 
     runEventLoop();
 
+#if PLATFORM(GTK)
+    g_main_context_pop_thread_default(mainContext.get());
+#endif
+
     ThreadIdentifier threadID = m_threadID;
 
     ASSERT(m_workerGlobalScope->hasOneRef());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to