Title: [210176] releases/WebKitGTK/webkit-2.14/Source/WebCore
Revision
210176
Author
[email protected]
Date
2016-12-27 09:02:01 -0800 (Tue, 27 Dec 2016)

Log Message

Merge r205852 - [GTK] Crash of WebProcess on the last WebView disconnect (take two)
https://bugs.webkit.org/show_bug.cgi?id=161842

Reviewed by Michael Catanzaro.

The problem is that when PlatformDisplayX11 is destroyed, the sharing GL context is deleted and its destructor
makes a downcast of PlatformDisplay to get the native X11 display. We could simply keep a pointer to the native
X11 display in GLContextGLX, got at construction time from the PlatformDisplay, and ensure the sharing GL
context is deleted before the native X11 display is closed.

* platform/graphics/PlatformDisplay.h: Make m_sharingGLContext protected.
* platform/graphics/glx/GLContextGLX.cpp:
(WebCore::GLContextGLX::GLContextGLX): Initialize m_x11Display.
(WebCore::GLContextGLX::~GLContextGLX): Use m_x11Display and remove confusing comment about possible crash with
nviedia closed drivers.
(WebCore::GLContextGLX::defaultFrameBufferSize): Use m_x11Display.
(WebCore::GLContextGLX::makeContextCurrent): Ditto.
(WebCore::GLContextGLX::swapBuffers): Ditto.
(WebCore::GLContextGLX::swapInterval): Ditto.
(WebCore::GLContextGLX::cairoDevice): Ditto.
* platform/graphics/glx/GLContextGLX.h:
* platform/graphics/x11/PlatformDisplayX11.cpp:
(WebCore::PlatformDisplayX11::~PlatformDisplayX11): Delete the sharing GL context before closing the display.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog (210175 => 210176)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2016-12-27 16:44:37 UTC (rev 210175)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2016-12-27 17:02:01 UTC (rev 210176)
@@ -1,3 +1,29 @@
+2016-09-12  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Crash of WebProcess on the last WebView disconnect (take two)
+        https://bugs.webkit.org/show_bug.cgi?id=161842
+
+        Reviewed by Michael Catanzaro.
+
+        The problem is that when PlatformDisplayX11 is destroyed, the sharing GL context is deleted and its destructor
+        makes a downcast of PlatformDisplay to get the native X11 display. We could simply keep a pointer to the native
+        X11 display in GLContextGLX, got at construction time from the PlatformDisplay, and ensure the sharing GL
+        context is deleted before the native X11 display is closed.
+
+        * platform/graphics/PlatformDisplay.h: Make m_sharingGLContext protected.
+        * platform/graphics/glx/GLContextGLX.cpp:
+        (WebCore::GLContextGLX::GLContextGLX): Initialize m_x11Display.
+        (WebCore::GLContextGLX::~GLContextGLX): Use m_x11Display and remove confusing comment about possible crash with
+        nviedia closed drivers.
+        (WebCore::GLContextGLX::defaultFrameBufferSize): Use m_x11Display.
+        (WebCore::GLContextGLX::makeContextCurrent): Ditto.
+        (WebCore::GLContextGLX::swapBuffers): Ditto.
+        (WebCore::GLContextGLX::swapInterval): Ditto.
+        (WebCore::GLContextGLX::cairoDevice): Ditto.
+        * platform/graphics/glx/GLContextGLX.h:
+        * platform/graphics/x11/PlatformDisplayX11.cpp:
+        (WebCore::PlatformDisplayX11::~PlatformDisplayX11): Delete the sharing GL context before closing the display.
+
 2016-12-20  Carlos Garcia Campos  <[email protected]>
 
         [Cairo] Conditional jump or move depends on uninitialised value(s)

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/PlatformDisplay.h (210175 => 210176)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/PlatformDisplay.h	2016-12-27 16:44:37 UTC (rev 210175)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/PlatformDisplay.h	2016-12-27 17:02:01 UTC (rev 210176)
@@ -80,6 +80,10 @@
     EGLDisplay m_eglDisplay;
 #endif
 
+#if USE(EGL) || USE(GLX)
+    std::unique_ptr<GLContext> m_sharingGLContext;
+#endif
+
 private:
     static std::unique_ptr<PlatformDisplay> createPlatformDisplay();
 
@@ -90,9 +94,6 @@
     int m_eglMajorVersion { 0 };
     int m_eglMinorVersion { 0 };
 #endif
-#if USE(EGL) || USE(GLX)
-    std::unique_ptr<GLContext> m_sharingGLContext;
-#endif
 };
 
 } // namespace WebCore

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp (210175 => 210176)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp	2016-12-27 16:44:37 UTC (rev 210175)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp	2016-12-27 17:02:01 UTC (rev 210176)
@@ -249,6 +249,7 @@
 
 GLContextGLX::GLContextGLX(PlatformDisplay& display, XUniqueGLXContext&& context, GLNativeWindowType window)
     : GLContext(display)
+    , m_x11Display(downcast<PlatformDisplayX11>(m_display).native())
     , m_context(WTFMove(context))
     , m_window(static_cast<Window>(window))
 {
@@ -256,6 +257,7 @@
 
 GLContextGLX::GLContextGLX(PlatformDisplay& display, XUniqueGLXContext&& context, XUniqueGLXPbuffer&& pbuffer)
     : GLContext(display)
+    , m_x11Display(downcast<PlatformDisplayX11>(m_display).native())
     , m_context(WTFMove(context))
     , m_pbuffer(WTFMove(pbuffer))
 {
@@ -263,6 +265,7 @@
 
 GLContextGLX::GLContextGLX(PlatformDisplay& display, XUniqueGLXContext&& context, XUniquePixmap&& pixmap, XUniqueGLXPixmap&& glxPixmap)
     : GLContext(display)
+    , m_x11Display(downcast<PlatformDisplayX11>(m_display).native())
     , m_context(WTFMove(context))
     , m_pixmap(WTFMove(pixmap))
     , m_glxPixmap(WTFMove(glxPixmap))
@@ -276,7 +279,7 @@
 
     if (m_context) {
         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-        glXMakeCurrent(downcast<PlatformDisplayX11>(m_display).native(), None, None);
+        glXMakeCurrent(m_x11Display, None, None);
     }
 }
 
@@ -293,7 +296,7 @@
     int x, y;
     Window rootWindow;
     unsigned int width, height, borderWidth, depth;
-    if (!XGetGeometry(downcast<PlatformDisplayX11>(m_display).native(), m_window, &rootWindow, &x, &y, &width, &height, &borderWidth, &depth))
+    if (!XGetGeometry(m_x11Display, m_window, &rootWindow, &x, &y, &width, &height, &borderWidth, &depth))
         return IntSize();
 
     return IntSize(width, height);
@@ -307,20 +310,19 @@
     if (glXGetCurrentContext() == m_context.get())
         return true;
 
-    Display* display = downcast<PlatformDisplayX11>(m_display).native();
     if (m_window)
-        return glXMakeCurrent(display, m_window, m_context.get());
+        return glXMakeCurrent(m_x11Display, m_window, m_context.get());
 
     if (m_pbuffer)
-        return glXMakeCurrent(display, m_pbuffer.get(), m_context.get());
+        return glXMakeCurrent(m_x11Display, m_pbuffer.get(), m_context.get());
 
-    return ::glXMakeCurrent(display, m_glxPixmap.get(), m_context.get());
+    return ::glXMakeCurrent(m_x11Display, m_glxPixmap.get(), m_context.get());
 }
 
 void GLContextGLX::swapBuffers()
 {
     if (m_window)
-        glXSwapBuffers(downcast<PlatformDisplayX11>(m_display).native(), m_window);
+        glXSwapBuffers(m_x11Display, m_window);
 }
 
 void GLContextGLX::waitNative()
@@ -330,7 +332,7 @@
 
 void GLContextGLX::swapInterval(int interval)
 {
-    if (!hasSGISwapControlExtension(downcast<PlatformDisplayX11>(m_display).native()))
+    if (!hasSGISwapControlExtension(m_x11Display))
         return;
     glXSwapIntervalSGI(interval);
 }
@@ -341,7 +343,7 @@
         return m_cairoDevice;
 
 #if ENABLE(ACCELERATED_2D_CANVAS) && CAIRO_HAS_GLX_FUNCTIONS
-    m_cairoDevice = cairo_glx_device_create(downcast<PlatformDisplayX11>(m_display).native(), m_context.get());
+    m_cairoDevice = cairo_glx_device_create(m_x11Display, m_context.get());
 #endif
 
     return m_cairoDevice;

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/glx/GLContextGLX.h (210175 => 210176)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/glx/GLContextGLX.h	2016-12-27 16:44:37 UTC (rev 210175)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/glx/GLContextGLX.h	2016-12-27 17:02:01 UTC (rev 210176)
@@ -28,6 +28,7 @@
 typedef unsigned char GLubyte;
 typedef unsigned long Window;
 typedef void* ContextKeyType;
+typedef struct _XDisplay Display;
 
 namespace WebCore {
 
@@ -61,6 +62,7 @@
     static std::unique_ptr<GLContextGLX> createPbufferContext(PlatformDisplay&, GLXContext sharingContext = nullptr);
     static std::unique_ptr<GLContextGLX> createPixmapContext(PlatformDisplay&, GLXContext sharingContext = nullptr);
 
+    Display* m_x11Display { nullptr };
     XUniqueGLXContext m_context;
     Window m_window { 0 };
     XUniqueGLXPbuffer m_pbuffer;

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp (210175 => 210176)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp	2016-12-27 16:44:37 UTC (rev 210175)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp	2016-12-27 17:02:01 UTC (rev 210176)
@@ -56,6 +56,10 @@
 
 PlatformDisplayX11::~PlatformDisplayX11()
 {
+#if USE(EGL) || USE(GLX)
+    // Clear the sharing context before releasing the display.
+    m_sharingGLContext = nullptr;
+#endif
     if (m_ownedDisplay)
         XCloseDisplay(m_display);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to