Title: [211789] releases/WebKitGTK/webkit-2.14/Source/WebKit2
Revision
211789
Author
carlo...@webkit.org
Date
2017-02-07 01:33:12 -0800 (Tue, 07 Feb 2017)

Log Message

Merge r211281 - [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:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog (211788 => 211789)


--- releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog	2017-02-07 09:33:06 UTC (rev 211788)
+++ releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog	2017-02-07 09:33:12 UTC (rev 211789)
@@ -1,3 +1,28 @@
+2017-01-27  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [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:
+
 2017-01-26  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [Threaded Compositor] Update also the contents size when creating the threaded compositor

Modified: releases/WebKitGTK/webkit-2.14/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp (211788 => 211789)


--- releases/WebKitGTK/webkit-2.14/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp	2017-02-07 09:33:06 UTC (rev 211788)
+++ releases/WebKitGTK/webkit-2.14/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp	2017-02-07 09:33:12 UTC (rev 211789)
@@ -59,7 +59,11 @@
 {
     m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] {
         m_scene = adoptRef(new CoordinatedGraphicsScene(this));
-        m_scene->setActive(!!m_nativeSurfaceHandle);
+        if (m_nativeSurfaceHandle) {
+            createGLContext();
+            m_scene->setActive(true);
+        } else
+            m_scene->setActive(false);
     });
 }
 
@@ -67,6 +71,21 @@
 {
 }
 
+void ThreadedCompositor::createGLContext()
+{
+    ASSERT(!isMainThread());
+    ASSERT(m_nativeSurfaceHandle);
+
+    m_context = GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(m_nativeSurfaceHandle), &PlatformDisplay::sharedDisplayForCompositing());
+    if (!m_context)
+        return;
+
+    if (m_doFrameSync == ShouldDoFrameSync::No) {
+        if (m_context->makeContextCurrent())
+            m_context->swapInterval(0);
+    }
+}
+
 void ThreadedCompositor::invalidate()
 {
     m_scene->detach();
@@ -83,13 +102,16 @@
 {
     m_compositingRunLoop->stopUpdateTimer();
     m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this), handle] {
-        m_scene->setActive(!!handle);
-
         // A new native handle can't be set without destroying the previous one first if any.
         ASSERT(!!handle ^ !!m_nativeSurfaceHandle);
         m_nativeSurfaceHandle = handle;
-        if (!m_nativeSurfaceHandle)
+        if (m_nativeSurfaceHandle) {
+            createGLContext();
+            m_scene->setActive(true);
+        } else {
+            m_scene->setActive(false);
             m_context = nullptr;
+        }
     });
 }
 
@@ -150,27 +172,6 @@
     m_compositingRunLoop->startUpdateTimer(CompositingRunLoop::Immediate);
 }
 
-bool ThreadedCompositor::makeContextCurrent()
-{
-    if (m_context)
-        return m_context->makeContextCurrent();
-
-    if (!m_nativeSurfaceHandle)
-        return false;
-
-    m_context = GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(m_nativeSurfaceHandle), &PlatformDisplay::sharedDisplayForCompositing());
-    if (!m_context)
-        return false;
-
-    if (!m_context->makeContextCurrent())
-        return false;
-
-    if (m_doFrameSync == ShouldDoFrameSync::No)
-        m_context->swapInterval(0);
-
-    return true;
-}
-
 void ThreadedCompositor::forceRepaint()
 {
     m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] {
@@ -183,7 +184,7 @@
     if (!m_scene || !m_scene->isActive())
         return;
 
-    if (!makeContextCurrent())
+    if (!m_context || !m_context->makeContextCurrent())
         return;
 
     if (m_needsResize) {

Modified: releases/WebKitGTK/webkit-2.14/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h (211788 => 211789)


--- releases/WebKitGTK/webkit-2.14/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h	2017-02-07 09:33:06 UTC (rev 211788)
+++ releases/WebKitGTK/webkit-2.14/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h	2017-02-07 09:33:12 UTC (rev 211789)
@@ -84,7 +84,7 @@
     void renderLayerTree();
     void scheduleDisplayImmediately();
 
-    bool makeContextCurrent();
+    void createGLContext();
 
     Client& m_client;
     RefPtr<CoordinatedGraphicsScene> m_scene;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to