Title: [260301] trunk/Source/WebCore
Revision
260301
Author
d...@apple.com
Date
2020-04-17 16:30:33 -0700 (Fri, 17 Apr 2020)

Log Message

[WebGL] Confirm there are no errors when setting up framebuffers
https://bugs.webkit.org/show_bug.cgi?id=210632
<rdar://problem/61916680>

Reviewed by Simon Fraser.

We're seeing crashes on macOS inside GraphicsContextGL::reshape().
Specifically when we submit work at the end of the function via
glFlush.

At the moment the cause is a mystery, because we should bail out
before then if the multisample renderbuffer was not complete. In
the hope that it helps somewhat, add a call to glGetError to double
check that there isn't anything horribly wrong before we talk to
the GPU.

* html/canvas/WebGL2RenderingContext.cpp:
(WebCore::WebGL2RenderingContext::WebGL2RenderingContext): If the underlying
GCGL context was marked as "LOST" during initialization, skip the rest of our
initialization.
* html/canvas/WebGLRenderingContext.cpp: Ditto.
(WebCore::WebGLRenderingContext::WebGLRenderingContext):
* html/canvas/WebGLRenderingContextBase.cpp: Ditto.
(WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase):

* platform/graphics/angle/GraphicsContextGLANGLE.cpp: Check for a GL error during
setup and, if there is one, skip directly into a LOST state.
(WebCore::GraphicsContextGLOpenGL::reshape):
* platform/graphics/opengl/GraphicsContextGLOpenGLCommon.cpp:
(WebCore::GraphicsContextGLOpenGL::reshape):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (260300 => 260301)


--- trunk/Source/WebCore/ChangeLog	2020-04-17 23:13:56 UTC (rev 260300)
+++ trunk/Source/WebCore/ChangeLog	2020-04-17 23:30:33 UTC (rev 260301)
@@ -1,3 +1,36 @@
+2020-04-17  Dean Jackson  <d...@apple.com>
+
+        [WebGL] Confirm there are no errors when setting up framebuffers
+        https://bugs.webkit.org/show_bug.cgi?id=210632
+        <rdar://problem/61916680>
+
+        Reviewed by Simon Fraser.
+
+        We're seeing crashes on macOS inside GraphicsContextGL::reshape().
+        Specifically when we submit work at the end of the function via
+        glFlush.
+
+        At the moment the cause is a mystery, because we should bail out
+        before then if the multisample renderbuffer was not complete. In
+        the hope that it helps somewhat, add a call to glGetError to double
+        check that there isn't anything horribly wrong before we talk to
+        the GPU.
+
+        * html/canvas/WebGL2RenderingContext.cpp:
+        (WebCore::WebGL2RenderingContext::WebGL2RenderingContext): If the underlying
+        GCGL context was marked as "LOST" during initialization, skip the rest of our
+        initialization.
+        * html/canvas/WebGLRenderingContext.cpp: Ditto.
+        (WebCore::WebGLRenderingContext::WebGLRenderingContext):
+        * html/canvas/WebGLRenderingContextBase.cpp: Ditto.
+        (WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase):
+
+        * platform/graphics/angle/GraphicsContextGLANGLE.cpp: Check for a GL error during
+        setup and, if there is one, skip directly into a LOST state.
+        (WebCore::GraphicsContextGLOpenGL::reshape):
+        * platform/graphics/opengl/GraphicsContextGLOpenGLCommon.cpp:
+        (WebCore::GraphicsContextGLOpenGL::reshape):
+
 2020-04-17  Peng Liu  <peng.l...@apple.com>
 
         Cleanup the macros for video fullscreen and picture-in-picture

Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp (260300 => 260301)


--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp	2020-04-17 23:13:56 UTC (rev 260300)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp	2020-04-17 23:30:33 UTC (rev 260301)
@@ -96,6 +96,9 @@
 WebGL2RenderingContext::WebGL2RenderingContext(CanvasBase& canvas, Ref<GraphicsContextGLOpenGL>&& context, GraphicsContextGLAttributes attributes)
     : WebGLRenderingContextBase(canvas, WTFMove(context), attributes)
 {
+    if (isContextLost())
+        return;
+
     initializeShaderExtensions();
     initializeVertexArrayObjects();
     initializeTransformFeedbackBufferCache();

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (260300 => 260301)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2020-04-17 23:13:56 UTC (rev 260300)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2020-04-17 23:30:33 UTC (rev 260301)
@@ -99,6 +99,9 @@
 WebGLRenderingContext::WebGLRenderingContext(CanvasBase& canvas, Ref<GraphicsContextGLOpenGL>&& context, GraphicsContextGLAttributes attributes)
     : WebGLRenderingContextBase(canvas, WTFMove(context), attributes)
 {
+    if (isContextLost())
+        return;
+
     initializeVertexArrayObjects();
 }
 

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (260300 => 260301)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2020-04-17 23:13:56 UTC (rev 260300)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2020-04-17 23:30:33 UTC (rev 260301)
@@ -648,6 +648,12 @@
 
     setupFlags();
     initializeNewContext();
+
+    // If something goes wrong in initializeNewContext, it should have
+    // triggered a lost context. Check that before setting anything else up.
+    if (isContextLost())
+        return;
+
     registerWithWebGLStateTracker();
     m_checkForContextLossHandlingTimer.startOneShot(checkContextLossHandlingDelay);
 

Modified: trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp (260300 => 260301)


--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp	2020-04-17 23:13:56 UTC (rev 260300)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp	2020-04-17 23:30:33 UTC (rev 260301)
@@ -623,6 +623,13 @@
             gl::BindFramebuffer(GraphicsContextGL::READ_FRAMEBUFFER, m_state.boundReadFBO);
     }
 
+    auto error = gl::GetError();
+    if (error != GL_NO_ERROR) {
+        RELEASE_LOG(WebGL, "Fatal: OpenGL error during GraphicsContextGL buffer initialization (%d).", error);
+        forceContextLost();
+        return;
+    }
+
     gl::Flush();
 }
 

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLCommon.cpp (260300 => 260301)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLCommon.cpp	2020-04-17 23:13:56 UTC (rev 260300)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLCommon.cpp	2020-04-17 23:30:33 UTC (rev 260301)
@@ -372,6 +372,13 @@
     if (mustRestoreFBO)
         ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_state.boundDrawFBO);
 
+    auto error = ::glGetError();
+    if (error != GL_NO_ERROR) {
+        RELEASE_LOG(WebGL, "Fatal: OpenGL error during GraphicsContextGL buffer initialization (%d).", error);
+        forceContextLost();
+        return;
+    }
+
     ::glFlush();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to