Title: [211281] trunk/Source/WebKit2
Revision
211281
Author
[email protected]
Date
2017-01-27 04:10:56 -0800 (Fri, 27 Jan 2017)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (211280 => 211281)


--- trunk/Source/WebKit2/ChangeLog	2017-01-27 10:49:23 UTC (rev 211280)
+++ trunk/Source/WebKit2/ChangeLog	2017-01-27 12:10:56 UTC (rev 211281)
@@ -1,5 +1,30 @@
 2017-01-27  Carlos Garcia Campos  <[email protected]>
 
+        [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-27  Carlos Garcia Campos  <[email protected]>
+
         [GTK] Stop forcing accelerated compositing by default
         https://bugs.webkit.org/show_bug.cgi?id=167492
 

Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp (211280 => 211281)


--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp	2017-01-27 10:49:23 UTC (rev 211280)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp	2017-01-27 12:10:56 UTC (rev 211281)
@@ -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: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h (211280 => 211281)


--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h	2017-01-27 10:49:23 UTC (rev 211280)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h	2017-01-27 12:10:56 UTC (rev 211281)
@@ -84,7 +84,7 @@
     void renderLayerTree();
     void scheduleDisplayImmediately();
 
-    bool makeContextCurrent();
+    void createGLContext();
 
     Client& m_client;
     RefPtr<CoordinatedGraphicsScene> m_scene;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to