Changeset 195537 in webkit


Ignore:
Timestamp:
Jan 25, 2016 9:13:40 AM (8 years ago)
Author:
Carlos Garcia Campos
Message:

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 JavaScriptCore 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):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r195535 r195537  
     12016-01-25  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        REGRESSION(r192773): [GTK] maps.google.com unresponsive/stalls since r192773
     4        https://bugs.webkit.org/show_bug.cgi?id=153194
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        In r192773 we implemented the JavaScriptCore garbage collector
     9        timers for the GTK+ port. Those timers schedule sources in the
     10        current thread default main context, but JS web worker threads
     11        implementation doesn't use WTF::RunLoop, but its own WorkerRunLoop
     12        class that doesn't create a GMainContext for the new thread. This
     13        means that for web sites using workers, we are now doing garbage
     14        collection of worker VMs in the main thread which ends up in a
     15        deadlock at some point. We need to ensure that worker threads
     16        create a GMainContext and push it as the default one for the
     17        thread before the WorkerGlobalScope is created. This way when the
     18        worker Heap is created, the GC timers use the right context to
     19        schedule their sources. And then we need to check if there are
     20        sources pending in the thread main context on every worker run
     21        loop iteration.
     22
     23        * workers/WorkerRunLoop.cpp:
     24        (WebCore::WorkerRunLoop::runInMode):
     25        * workers/WorkerThread.cpp:
     26        (WebCore::WorkerThread::workerThread):
     27
    1282016-01-25  Commit Queue  <commit-queue@webkit.org>
    229
  • trunk/Source/WebCore/workers/WorkerRunLoop.cpp

    r194496 r195537  
    4040#include <wtf/CurrentTime.h>
    4141
     42#if PLATFORM(GTK)
     43#include <glib.h>
     44#endif
     45
    4246namespace WebCore {
    4347
     
    143147    ASSERT(context->thread().threadID() == currentThread());
    144148
     149#if PLATFORM(GTK)
     150    GMainContext* mainContext = g_main_context_get_thread_default();
     151    if (g_main_context_pending(mainContext))
     152        g_main_context_iteration(mainContext, FALSE);
     153#endif
     154
    145155    double deadline = MessageQueue<Task>::infiniteTime();
    146156
  • trunk/Source/WebCore/workers/WorkerThread.cpp

    r193426 r195537  
    4545#endif
    4646
     47#if PLATFORM(GTK)
     48#include <wtf/glib/GRefPtr.h>
     49#endif
     50
    4751namespace WebCore {
    4852
     
    135139#endif
    136140
     141#if PLATFORM(GTK)
     142    GRefPtr<GMainContext> mainContext = adoptGRef(g_main_context_new());
     143    g_main_context_push_thread_default(mainContext.get());
     144#endif
     145
    137146    {
    138147        LockHolder lock(m_threadCreationMutex);
     
    154163
    155164    runEventLoop();
     165
     166#if PLATFORM(GTK)
     167    g_main_context_pop_thread_default(mainContext.get());
     168#endif
    156169
    157170    ThreadIdentifier threadID = m_threadID;
Note: See TracChangeset for help on using the changeset viewer.