Title: [115285] trunk/Source
Revision
115285
Author
commit-qu...@webkit.org
Date
2012-04-25 21:50:28 -0700 (Wed, 25 Apr 2012)

Log Message

[chromium] REGRESSION(112286) Compositor initialization blocks for program compilation / linking
https://bugs.webkit.org/show_bug.cgi?id=84822

Patch by James Robinson <jam...@chromium.org> on 2012-04-25
Reviewed by Adrienne Walker.

Source/WebCore:

r112286 introduced a subtle regression in the chromium compositor startup sequence - by querying the texture
copy program's uniform location at the end of LayerRendererChromium::initialize(), the compositor's thread was
blocked until the service side compiled _all_ eagerly initialized shaders. The intent of the way the compositor
programs are created is that a set of commonly-used programs are sent to the service side, but no blocking calls
are made until after we go through the first paint (with the hope that the service side will complete the
compilation by then).

Fixed by moving program initialization (which also grabs uniform locations) until the first actual use of the
copier. It may be worth deferring the program initialization completely if it's not used very often.

Added unit test in LayerRendererChromiumTests to make sure LRC initialization does not make any
synchronous calls (like getUniformLocation()).

* platform/graphics/chromium/TextureCopier.cpp:
(WebCore::AcceleratedTextureCopier::AcceleratedTextureCopier):
(WebCore::AcceleratedTextureCopier::copyTexture):

Source/WebKit/chromium:

Add a test that makes sure we don't make blocking calls during LayerRendererChromium initialization.

* tests/LayerRendererChromiumTest.cpp:
(ForbidSynchronousCallContext):
(ForbidSynchronousCallContext::ForbidSynchronousCallContext):
(ForbidSynchronousCallContext::finish):
(ForbidSynchronousCallContext::getActiveAttrib):
(ForbidSynchronousCallContext::getActiveUniform):
(ForbidSynchronousCallContext::getAttachedShaders):
(ForbidSynchronousCallContext::getAttribLocation):
(ForbidSynchronousCallContext::getBooleanv):
(ForbidSynchronousCallContext::getBufferParameteriv):
(ForbidSynchronousCallContext::getContextAttributes):
(ForbidSynchronousCallContext::getError):
(ForbidSynchronousCallContext::getFloatv):
(ForbidSynchronousCallContext::getFramebufferAttachmentParameteriv):
(TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (115284 => 115285)


--- trunk/Source/WebCore/ChangeLog	2012-04-26 04:03:27 UTC (rev 115284)
+++ trunk/Source/WebCore/ChangeLog	2012-04-26 04:50:28 UTC (rev 115285)
@@ -1,3 +1,27 @@
+2012-04-25  James Robinson  <jam...@chromium.org>
+
+        [chromium] REGRESSION(112286) Compositor initialization blocks for program compilation / linking
+        https://bugs.webkit.org/show_bug.cgi?id=84822
+
+        Reviewed by Adrienne Walker.
+
+        r112286 introduced a subtle regression in the chromium compositor startup sequence - by querying the texture
+        copy program's uniform location at the end of LayerRendererChromium::initialize(), the compositor's thread was
+        blocked until the service side compiled _all_ eagerly initialized shaders. The intent of the way the compositor
+        programs are created is that a set of commonly-used programs are sent to the service side, but no blocking calls
+        are made until after we go through the first paint (with the hope that the service side will complete the
+        compilation by then).
+
+        Fixed by moving program initialization (which also grabs uniform locations) until the first actual use of the
+        copier. It may be worth deferring the program initialization completely if it's not used very often.
+
+        Added unit test in LayerRendererChromiumTests to make sure LRC initialization does not make any
+        synchronous calls (like getUniformLocation()).
+
+        * platform/graphics/chromium/TextureCopier.cpp:
+        (WebCore::AcceleratedTextureCopier::AcceleratedTextureCopier):
+        (WebCore::AcceleratedTextureCopier::copyTexture):
+
 2012-04-25  Jason Liu  <jason....@torchmobile.com.cn>
 
         [BlackBerry] Authenticated proxy isn't working.

Modified: trunk/Source/WebCore/platform/graphics/chromium/ProgramBinding.h (115284 => 115285)


--- trunk/Source/WebCore/platform/graphics/chromium/ProgramBinding.h	2012-04-26 04:03:27 UTC (rev 115284)
+++ trunk/Source/WebCore/platform/graphics/chromium/ProgramBinding.h	2012-04-26 04:50:28 UTC (rev 115285)
@@ -43,7 +43,7 @@
     void init(GraphicsContext3D*, const String& vertexShader, const String& fragmentShader);
     void cleanup(GraphicsContext3D*);
 
-    unsigned program() const { return m_program; }
+    unsigned program() const { ASSERT(m_initialized); return m_program; }
     bool initialized() const { return m_initialized; }
 
 protected:
@@ -67,6 +67,7 @@
     {
         ASSERT(context);
         ASSERT(m_program);
+        ASSERT(!m_initialized);
 
         m_vertexShader.init(context, m_program);
         m_fragmentShader.init(context, m_program);

Modified: trunk/Source/WebCore/platform/graphics/chromium/TextureCopier.cpp (115284 => 115285)


--- trunk/Source/WebCore/platform/graphics/chromium/TextureCopier.cpp	2012-04-26 04:03:27 UTC (rev 115284)
+++ trunk/Source/WebCore/platform/graphics/chromium/TextureCopier.cpp	2012-04-26 04:50:28 UTC (rev 115285)
@@ -49,7 +49,6 @@
     GLC(m_context.get(), m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0));
 
     m_blitProgram = adoptPtr(new BlitProgram(m_context.get()));
-    m_blitProgram->initialize(m_context.get());
 }
 
 AcceleratedTextureCopier::~AcceleratedTextureCopier()
@@ -80,6 +79,9 @@
     GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::NEAREST));
     GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::NEAREST));
 
+    if (!m_blitProgram->initialized())
+        m_blitProgram->initialize(context);
+
     // TODO: Use EXT_framebuffer_blit if available.
     GLC(context, context->useProgram(m_blitProgram->program()));
 

Modified: trunk/Source/WebKit/chromium/ChangeLog (115284 => 115285)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-04-26 04:03:27 UTC (rev 115284)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-04-26 04:50:28 UTC (rev 115285)
@@ -1,3 +1,28 @@
+2012-04-25  James Robinson  <jam...@chromium.org>
+
+        [chromium] REGRESSION(112286) Compositor initialization blocks for program compilation / linking
+        https://bugs.webkit.org/show_bug.cgi?id=84822
+
+        Reviewed by Adrienne Walker.
+
+        Add a test that makes sure we don't make blocking calls during LayerRendererChromium initialization.
+
+        * tests/LayerRendererChromiumTest.cpp:
+        (ForbidSynchronousCallContext):
+        (ForbidSynchronousCallContext::ForbidSynchronousCallContext):
+        (ForbidSynchronousCallContext::finish):
+        (ForbidSynchronousCallContext::getActiveAttrib):
+        (ForbidSynchronousCallContext::getActiveUniform):
+        (ForbidSynchronousCallContext::getAttachedShaders):
+        (ForbidSynchronousCallContext::getAttribLocation):
+        (ForbidSynchronousCallContext::getBooleanv):
+        (ForbidSynchronousCallContext::getBufferParameteriv):
+        (ForbidSynchronousCallContext::getContextAttributes):
+        (ForbidSynchronousCallContext::getError):
+        (ForbidSynchronousCallContext::getFloatv):
+        (ForbidSynchronousCallContext::getFramebufferAttachmentParameteriv):
+        (TEST):
+
 2012-04-25  Alec Flett  <alecfl...@chromium.org>
 
         IndexedDB: implement cursor.advance()

Modified: trunk/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp (115284 => 115285)


--- trunk/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp	2012-04-26 04:03:27 UTC (rev 115284)
+++ trunk/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp	2012-04-26 04:50:28 UTC (rev 115285)
@@ -199,3 +199,78 @@
     swapBuffers();
     EXPECT_EQ(1, m_mockContext.frameCount());
 }
+
+class ForbidSynchronousCallContext : public FakeWebGraphicsContext3D {
+public:
+    ForbidSynchronousCallContext() { }
+
+    virtual bool getActiveAttrib(WebGLId program, WGC3Duint index, ActiveInfo&) { ADD_FAILURE(); return false; }
+    virtual bool getActiveUniform(WebGLId program, WGC3Duint index, ActiveInfo&) { ADD_FAILURE(); return false; }
+    virtual void getAttachedShaders(WebGLId program, WGC3Dsizei maxCount, WGC3Dsizei* count, WebGLId* shaders) { ADD_FAILURE(); }
+    virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name) { ADD_FAILURE(); return 0; }
+    virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value) { ADD_FAILURE(); }
+    virtual void getBufferParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Dint* value) { ADD_FAILURE(); }
+    virtual Attributes getContextAttributes() { ADD_FAILURE(); return m_attrs; }
+    virtual WGC3Denum getError() { ADD_FAILURE(); return 0; }
+    virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value) { ADD_FAILURE(); }
+    virtual void getFramebufferAttachmentParameteriv(WGC3Denum target, WGC3Denum attachment, WGC3Denum pname, WGC3Dint* value) { ADD_FAILURE(); }
+    virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value)
+    {
+        if (pname == WebCore::GraphicsContext3D::MAX_TEXTURE_SIZE)
+            *value = 1024; // MAX_TEXTURE_SIZE is cached client side, so it's OK to query.
+        else
+            ADD_FAILURE();
+    }
+
+    // We allow querying the shader compilation and program link status in debug mode, but not release.
+    virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value)
+    {
+#ifndef NDEBUG
+        *value = 1;
+#else
+        ADD_FAILURE();
+#endif
+    }
+
+    virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value)
+    {
+#ifndef NDEBUG
+        *value = 1;
+#else
+        ADD_FAILURE();
+#endif
+    }
+
+    virtual WebString getString(WGC3Denum name)
+    {
+        // We allow querying the extension string.
+        // FIXME: It'd be better to check that we only do this before starting any other expensive work (like starting a compilation)
+        if (name != WebCore::GraphicsContext3D::EXTENSIONS)
+            ADD_FAILURE();
+        return WebString();
+    }
+
+    virtual WebString getProgramInfoLog(WebGLId program) { ADD_FAILURE(); return WebString(); }
+    virtual void getRenderbufferParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Dint* value) { ADD_FAILURE(); }
+
+    virtual WebString getShaderInfoLog(WebGLId shader) { ADD_FAILURE(); return WebString(); }
+    virtual void getShaderPrecisionFormat(WGC3Denum shadertype, WGC3Denum precisiontype, WGC3Dint* range, WGC3Dint* precision) { ADD_FAILURE(); }
+    virtual WebString getShaderSource(WebGLId shader) { ADD_FAILURE(); return WebString(); }
+    virtual void getTexParameterfv(WGC3Denum target, WGC3Denum pname, WGC3Dfloat* value) { ADD_FAILURE(); }
+    virtual void getTexParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Dint* value) { ADD_FAILURE(); }
+    virtual void getUniformfv(WebGLId program, WGC3Dint location, WGC3Dfloat* value) { ADD_FAILURE(); }
+    virtual void getUniformiv(WebGLId program, WGC3Dint location, WGC3Dint* value) { ADD_FAILURE(); }
+    virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name) { ADD_FAILURE(); return 0; }
+    virtual void getVertexAttribfv(WGC3Duint index, WGC3Denum pname, WGC3Dfloat* value) { ADD_FAILURE(); }
+    virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname, WGC3Dint* value) { ADD_FAILURE(); }
+    virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname) { ADD_FAILURE(); return 0; }
+};
+
+// This test isn't using the same fixture as LayerRendererChromiumTest, and you can't mix TEST() and TEST_F() with the same name, hence LRC2.
+TEST(LayerRendererChromiumTest2, initializationDoesNotMakeSynchronousCalls)
+{
+    FakeLayerRendererChromiumClient mockClient;
+    FakeLayerRendererChromium layerRendererChromium(&mockClient, GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ForbidSynchronousCallContext), GraphicsContext3D::RenderDirectlyToHostWindow));
+
+    EXPECT_TRUE(layerRendererChromium.initialize());
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to