Changeset 205852 in webkit


Ignore:
Timestamp:
Sep 12, 2016 11:12:42 PM (8 years ago)
Author:
Carlos Garcia Campos
Message:

[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.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r205847 r205852  
     12016-09-12  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Crash of WebProcess on the last WebView disconnect (take two)
     4        https://bugs.webkit.org/show_bug.cgi?id=161842
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        The problem is that when PlatformDisplayX11 is destroyed, the sharing GL context is deleted and its destructor
     9        makes a downcast of PlatformDisplay to get the native X11 display. We could simply keep a pointer to the native
     10        X11 display in GLContextGLX, got at construction time from the PlatformDisplay, and ensure the sharing GL
     11        context is deleted before the native X11 display is closed.
     12
     13        * platform/graphics/PlatformDisplay.h: Make m_sharingGLContext protected.
     14        * platform/graphics/glx/GLContextGLX.cpp:
     15        (WebCore::GLContextGLX::GLContextGLX): Initialize m_x11Display.
     16        (WebCore::GLContextGLX::~GLContextGLX): Use m_x11Display and remove confusing comment about possible crash with
     17        nviedia closed drivers.
     18        (WebCore::GLContextGLX::defaultFrameBufferSize): Use m_x11Display.
     19        (WebCore::GLContextGLX::makeContextCurrent): Ditto.
     20        (WebCore::GLContextGLX::swapBuffers): Ditto.
     21        (WebCore::GLContextGLX::swapInterval): Ditto.
     22        (WebCore::GLContextGLX::cairoDevice): Ditto.
     23        * platform/graphics/glx/GLContextGLX.h:
     24        * platform/graphics/x11/PlatformDisplayX11.cpp:
     25        (WebCore::PlatformDisplayX11::~PlatformDisplayX11): Delete the sharing GL context before closing the display.
     26
    1272016-09-12  Chris Dumez  <cdumez@apple.com>
    228
  • trunk/Source/WebCore/platform/graphics/PlatformDisplay.h

    r205116 r205852  
    8181#endif
    8282
     83    std::unique_ptr<GLContext> m_sharingGLContext;
     84
    8385private:
    8486    static std::unique_ptr<PlatformDisplay> createPlatformDisplay();
     
    9193    int m_eglMinorVersion { 0 };
    9294#endif
    93     std::unique_ptr<GLContext> m_sharingGLContext;
    9495};
    9596
  • trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp

    r205116 r205852  
    159159GLContextGLX::GLContextGLX(PlatformDisplay& display, XUniqueGLXContext&& context, XID window)
    160160    : GLContext(display)
     161    , m_x11Display(downcast<PlatformDisplayX11>(m_display).native())
    161162    , m_context(WTFMove(context))
    162163    , m_window(window)
     
    166167GLContextGLX::GLContextGLX(PlatformDisplay& display, XUniqueGLXContext&& context, XUniqueGLXPbuffer&& pbuffer)
    167168    : GLContext(display)
     169    , m_x11Display(downcast<PlatformDisplayX11>(m_display).native())
    168170    , m_context(WTFMove(context))
    169171    , m_pbuffer(WTFMove(pbuffer))
     
    173175GLContextGLX::GLContextGLX(PlatformDisplay& display, XUniqueGLXContext&& context, XUniquePixmap&& pixmap, XUniqueGLXPixmap&& glxPixmap)
    174176    : GLContext(display)
     177    , m_x11Display(downcast<PlatformDisplayX11>(m_display).native())
    175178    , m_context(WTFMove(context))
    176179    , m_pixmap(WTFMove(pixmap))
     
    185188
    186189    if (m_context) {
    187         // This may be necessary to prevent crashes with NVidia's closed source drivers. Originally
    188         // from Mozilla's 3D canvas implementation at: http://bitbucket.org/ilmari/canvas3d/
    189190        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    190         glXMakeCurrent(downcast<PlatformDisplayX11>(m_display).native(), None, None);
     191        glXMakeCurrent(m_x11Display, None, None);
    191192    }
    192193}
     
    205206    Window rootWindow;
    206207    unsigned int width, height, borderWidth, depth;
    207     if (!XGetGeometry(downcast<PlatformDisplayX11>(m_display).native(), m_window, &rootWindow, &x, &y, &width, &height, &borderWidth, &depth))
     208    if (!XGetGeometry(m_x11Display, m_window, &rootWindow, &x, &y, &width, &height, &borderWidth, &depth))
    208209        return IntSize();
    209210
     
    219220        return true;
    220221
    221     Display* display = downcast<PlatformDisplayX11>(m_display).native();
    222222    if (m_window)
    223         return glXMakeCurrent(display, m_window, m_context.get());
     223        return glXMakeCurrent(m_x11Display, m_window, m_context.get());
    224224
    225225    if (m_pbuffer)
    226         return glXMakeCurrent(display, m_pbuffer.get(), m_context.get());
    227 
    228     return ::glXMakeCurrent(display, m_glxPixmap.get(), m_context.get());
     226        return glXMakeCurrent(m_x11Display, m_pbuffer.get(), m_context.get());
     227
     228    return ::glXMakeCurrent(m_x11Display, m_glxPixmap.get(), m_context.get());
    229229}
    230230
     
    232232{
    233233    if (m_window)
    234         glXSwapBuffers(downcast<PlatformDisplayX11>(m_display).native(), m_window);
     234        glXSwapBuffers(m_x11Display, m_window);
    235235}
    236236
     
    242242void GLContextGLX::swapInterval(int interval)
    243243{
    244     if (!hasSGISwapControlExtension(downcast<PlatformDisplayX11>(m_display).native()))
     244    if (!hasSGISwapControlExtension(m_x11Display))
    245245        return;
    246246    glXSwapIntervalSGI(interval);
     
    253253
    254254#if ENABLE(ACCELERATED_2D_CANVAS) && CAIRO_HAS_GLX_FUNCTIONS
    255     m_cairoDevice = cairo_glx_device_create(downcast<PlatformDisplayX11>(m_display).native(), m_context.get());
     255    m_cairoDevice = cairo_glx_device_create(m_x11Display, m_context.get());
    256256#endif
    257257
  • trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h

    r205116 r205852  
    3030typedef unsigned long XID;
    3131typedef void* ContextKeyType;
     32typedef struct _XDisplay Display;
    3233
    3334namespace WebCore {
     
    6364    static std::unique_ptr<GLContextGLX> createPixmapContext(PlatformDisplay&, GLXContext sharingContext = nullptr);
    6465
     66    Display* m_x11Display { nullptr };
    6567    XUniqueGLXContext m_context;
    6668    XID m_window { 0 };
  • trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp

    r204013 r205852  
    3636#if USE(EGL)
    3737#include <EGL/egl.h>
     38#include <EGL/eglplatform.h>
    3839#endif
     40
     41// FIXME: this needs to be here, after eglplatform.h, to avoid EGLNativeDisplayType to be defined as wl_display.
     42// Since we support Wayland and X11 to be built at the same time, but eglplatform.h defines are decided at compile time
     43// we need to ensure we only include eglplatform.h from X11 or Wayland specific files.
     44#include "GLContext.h"
    3945
    4046namespace WebCore {
     
    5460PlatformDisplayX11::~PlatformDisplayX11()
    5561{
     62    // Clear the sharing context before releasing the display.
     63    m_sharingGLContext = nullptr;
    5664    if (m_ownedDisplay)
    5765        XCloseDisplay(m_display);
Note: See TracChangeset for help on using the changeset viewer.