Changeset 202040 in webkit


Ignore:
Timestamp:
Jun 14, 2016 2:58:06 AM (8 years ago)
Author:
Carlos Garcia Campos
Message:

[ThreadedCompositor] Opening the inspector in a window causes a crash.
https://bugs.webkit.org/show_bug.cgi?id=154444

Reviewed by Žan Doberšek.

The threaded compositor doesn't handle the case of changing or removing the native surface handle. When the web
view is reparented, the current native surface handle is destroyed when the view is removed from the parent, and
a new one is created when added to the new parent. We need to handle this case in the threaded compositor.

  • Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp:

(WebKit::CompositingRunLoop::stopUpdateTimer): Allow users to stop the update timer.

  • Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h:
  • Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:

(WebKit::ThreadedCompositor::setNativeSurfaceHandleForCompositing): Use performTaskSync because this is called
from a synchronous IPC message and right after it returns, the current native surface is destroyed by the UI
process. So we need to ensure we finish all pending operations for the current native surface in the compositing
thread before it's destroyed. Then we enable or disable the scene depending on whether the native surface has
been created or destroyed and destroy the current context in case the new handle is 0.
(WebKit::ThreadedCompositor::tryEnsureGLContext): Just renamed to make it clear that it can fail.
(WebKit::ThreadedCompositor::glContext):
(WebKit::ThreadedCompositor::renderLayerTree): Return early if scene is not active.

  • WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:

(WebKit::ThreadedCoordinatedLayerTreeHost::setNativeSurfaceHandleForCompositing): Schedule a new layer flush
after the native surface handle changed.

Location:
trunk/Source/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r202038 r202040  
     12016-06-14  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [ThreadedCompositor] Opening the inspector in a window causes a crash.
     4        https://bugs.webkit.org/show_bug.cgi?id=154444
     5
     6        Reviewed by Žan Doberšek.
     7
     8        The threaded compositor doesn't handle the case of changing or removing the native surface handle. When the web
     9        view is reparented, the current native surface handle is destroyed when the view is removed from the parent, and
     10        a new one is created when added to the new parent. We need to handle this case in the threaded compositor.
     11
     12        * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp:
     13        (WebKit::CompositingRunLoop::stopUpdateTimer): Allow users to stop the update timer.
     14        * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h:
     15        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
     16        (WebKit::ThreadedCompositor::setNativeSurfaceHandleForCompositing): Use performTaskSync because this is called
     17        from a synchronous IPC message and right after it returns, the current native surface is destroyed by the UI
     18        process. So we need to ensure we finish all pending operations for the current native surface in the compositing
     19        thread before it's destroyed. Then we enable or disable the scene depending on whether the native surface has
     20        been created or destroyed and destroy the current context in case the new handle is 0.
     21        (WebKit::ThreadedCompositor::tryEnsureGLContext): Just renamed to make it clear that it can fail.
     22        (WebKit::ThreadedCompositor::glContext):
     23        (WebKit::ThreadedCompositor::renderLayerTree): Return early if scene is not active.
     24        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
     25        (WebKit::ThreadedCoordinatedLayerTreeHost::setNativeSurfaceHandleForCompositing): Schedule a new layer flush
     26        after the native surface handle changed.
     27
    1282016-06-14  Carlos Garcia Campos  <cgarcia@igalia.com>
    229
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp

    r202038 r202040  
    7272}
    7373
     74void CompositingRunLoop::stopUpdateTimer()
     75{
     76    m_updateTimer.stop();
     77}
     78
    7479void CompositingRunLoop::updateTimerFired()
    7580{
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h

    r202038 r202040  
    5151
    5252    void startUpdateTimer(UpdateTiming = Immediate);
     53    void stopUpdateTimer();
    5354
    5455    void run();
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp

    r202038 r202040  
    6262void ThreadedCompositor::setNativeSurfaceHandleForCompositing(uint64_t handle)
    6363{
    64     m_compositingRunLoop->performTask([this, protectedThis = Ref<ThreadedCompositor>(*this), handle] {
     64    m_compositingRunLoop->stopUpdateTimer();
     65    m_compositingRunLoop->performTaskSync([this, protectedThis = Ref<ThreadedCompositor>(*this), handle] {
     66        m_scene->setActive(!!handle);
     67
     68        // A new native handle can't be set without destroying the previous one first if any.
     69        ASSERT(!!handle ^ !!m_nativeSurfaceHandle);
    6570        m_nativeSurfaceHandle = handle;
    66         m_scene->setActive(true);
     71        if (!m_nativeSurfaceHandle)
     72            m_context = nullptr;
    6773    });
    6874}
     
    131137}
    132138
    133 bool ThreadedCompositor::ensureGLContext()
     139bool ThreadedCompositor::tryEnsureGLContext()
    134140{
    135141    if (!glContext())
     
    157163
    158164    if (!m_nativeSurfaceHandle)
    159         return 0;
     165        return nullptr;
    160166
    161167    m_context = GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(m_nativeSurfaceHandle), GLContext::sharingContext());
     
    182188{
    183189    ASSERT(&RunLoop::current() == &m_compositingRunLoop->runLoop());
    184     if (!m_scene)
     190    if (!m_scene || !m_scene->isActive())
    185191        return;
    186192
    187     if (!ensureGLContext())
     193    if (!tryEnsureGLContext())
    188194        return;
    189195
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h

    r202038 r202040  
    8989    void didChangeVisibleRect() override;
    9090
    91     bool ensureGLContext();
     91    bool tryEnsureGLContext();
    9292    WebCore::GLContext* glContext();
    9393
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp

    r201923 r202040  
    199199    m_layerTreeContext.contextID = handle;
    200200    m_compositor->setNativeSurfaceHandleForCompositing(handle);
     201    scheduleLayerFlush();
    201202}
    202203#endif
Note: See TracChangeset for help on using the changeset viewer.