Changeset 211281 in webkit


Ignore:
Timestamp:
Jan 27, 2017 4:10:56 AM (7 years ago)
Author:
Carlos Garcia Campos
Message:

[Threaded Compositor] Stop creating the GLContext on demand the first time makeContextCurrent is called
https://bugs.webkit.org/show_bug.cgi?id=167496

Reviewed by Žan Doberšek.

This is causing problems with animations when entering AC mode on demand. What happens is that the threaded
compositor is created, then the animation is scheduled and during the first animation iteration the GLContext is
created, making the first frame of the animation quite slow. In my computer creating the GLContext takes 0.8
seconds. If the animation duration is less than the time it takes to create the GLContext, the animation ends
without iterating. This causing timeouts in the bots in tests like
animations/animation-iteration-event-destroy-renderer.html that expect webkitAnimationIteration events that
never fire.

  • Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:

(WebKit::ThreadedCompositor::ThreadedCompositor): Create the GLContext right after the compositing thread is
created if we already have a native surface handle.
(WebKit::ThreadedCompositor::createGLContext): Helper to create the GLContext.
(WebKit::ThreadedCompositor::setNativeSurfaceHandleForCompositing): Create the GLContext when a native surface
handle is given.
(WebKit::ThreadedCompositor::makeContextCurrent): Deleted.
(WebKit::ThreadedCompositor::renderLayerTree): Make the context cunrrent directly here.

  • Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r211277 r211281  
     12017-01-27  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [Threaded Compositor] Stop creating the GLContext on demand the first time makeContextCurrent is called
     4        https://bugs.webkit.org/show_bug.cgi?id=167496
     5
     6        Reviewed by Žan Doberšek.
     7
     8        This is causing problems with animations when entering AC mode on demand. What happens is that the threaded
     9        compositor is created, then the animation is scheduled and during the first animation iteration the GLContext is
     10        created, making the first frame of the animation quite slow. In my computer creating the GLContext takes 0.8
     11        seconds. If the animation duration is less than the time it takes to create the GLContext, the animation ends
     12        without iterating. This causing timeouts in the bots in tests like
     13        animations/animation-iteration-event-destroy-renderer.html that expect webkitAnimationIteration events that
     14        never fire.
     15
     16        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
     17        (WebKit::ThreadedCompositor::ThreadedCompositor): Create the GLContext right after the compositing thread is
     18        created if we already have a native surface handle.
     19        (WebKit::ThreadedCompositor::createGLContext): Helper to create the GLContext.
     20        (WebKit::ThreadedCompositor::setNativeSurfaceHandleForCompositing): Create the GLContext when a native surface
     21        handle is given.
     22        (WebKit::ThreadedCompositor::makeContextCurrent): Deleted.
     23        (WebKit::ThreadedCompositor::renderLayerTree): Make the context cunrrent directly here.
     24        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
     25
    1262017-01-27  Carlos Garcia Campos  <cgarcia@igalia.com>
    227
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp

    r210954 r211281  
    6060    m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] {
    6161        m_scene = adoptRef(new CoordinatedGraphicsScene(this));
    62         m_scene->setActive(!!m_nativeSurfaceHandle);
     62        if (m_nativeSurfaceHandle) {
     63            createGLContext();
     64            m_scene->setActive(true);
     65        } else
     66            m_scene->setActive(false);
    6367    });
    6468}
     
    6670ThreadedCompositor::~ThreadedCompositor()
    6771{
     72}
     73
     74void ThreadedCompositor::createGLContext()
     75{
     76    ASSERT(!isMainThread());
     77    ASSERT(m_nativeSurfaceHandle);
     78
     79    m_context = GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(m_nativeSurfaceHandle), &PlatformDisplay::sharedDisplayForCompositing());
     80    if (!m_context)
     81        return;
     82
     83    if (m_doFrameSync == ShouldDoFrameSync::No) {
     84        if (m_context->makeContextCurrent())
     85            m_context->swapInterval(0);
     86    }
    6887}
    6988
     
    84103    m_compositingRunLoop->stopUpdateTimer();
    85104    m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this), handle] {
    86         m_scene->setActive(!!handle);
    87 
    88105        // A new native handle can't be set without destroying the previous one first if any.
    89106        ASSERT(!!handle ^ !!m_nativeSurfaceHandle);
    90107        m_nativeSurfaceHandle = handle;
    91         if (!m_nativeSurfaceHandle)
     108        if (m_nativeSurfaceHandle) {
     109            createGLContext();
     110            m_scene->setActive(true);
     111        } else {
     112            m_scene->setActive(false);
    92113            m_context = nullptr;
     114        }
    93115    });
    94116}
     
    151173}
    152174
    153 bool ThreadedCompositor::makeContextCurrent()
    154 {
    155     if (m_context)
    156         return m_context->makeContextCurrent();
    157 
    158     if (!m_nativeSurfaceHandle)
    159         return false;
    160 
    161     m_context = GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(m_nativeSurfaceHandle), &PlatformDisplay::sharedDisplayForCompositing());
    162     if (!m_context)
    163         return false;
    164 
    165     if (!m_context->makeContextCurrent())
    166         return false;
    167 
    168     if (m_doFrameSync == ShouldDoFrameSync::No)
    169         m_context->swapInterval(0);
    170 
    171     return true;
    172 }
    173 
    174175void ThreadedCompositor::forceRepaint()
    175176{
     
    184185        return;
    185186
    186     if (!makeContextCurrent())
     187    if (!m_context || !m_context->makeContextCurrent())
    187188        return;
    188189
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h

    r210954 r211281  
    8585    void scheduleDisplayImmediately();
    8686
    87     bool makeContextCurrent();
     87    void createGLContext();
    8888
    8989    Client& m_client;
Note: See TracChangeset for help on using the changeset viewer.