Changeset 140342 in webkit


Ignore:
Timestamp:
Jan 21, 2013 9:57:06 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[EFL][Qt][WebGl] Random crash in GraphicsContext3D::drawArrays
https://bugs.webkit.org/show_bug.cgi?id=107178

Patch by Viatcheslav Ostapenko <sl.ostapenko@samsung.com> on 2013-01-21
Reviewed by Noam Rosenthal.

Workaround for the problem in mesa when internal llvm pipe object is deleted
later than the screen object. Screen object is deleted because the corresponding
X server display connection closed.
Keep X server display connection open until program shutdown.
OffScreenRootWindow::display is now static, so there is no need to create
OffScreenRootWindow object on client side.

Fixes crash that appears during run of fast/canavs/webgl tests.

  • platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp:

(OffScreenRootWindow):
(WebCore::OffScreenRootWindow::DisplayConnection::DisplayConnection):
(DisplayConnection):
(WebCore::OffScreenRootWindow::DisplayConnection::~DisplayConnection):
(WebCore::OffScreenRootWindow::DisplayConnection::display):
(WebCore::OffScreenRootWindow::display):
(WebCore::OffScreenRootWindow::~OffScreenRootWindow):
(WebCore):
(WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
(WebCore::GraphicsSurfacePrivate::createSurface):
(WebCore::GraphicsSurfacePrivate::createPixmap):
(WebCore::GraphicsSurfacePrivate::makeCurrent):
(WebCore::GraphicsSurfacePrivate::doneCurrent):
(WebCore::GraphicsSurfacePrivate::swapBuffers):
(WebCore::GraphicsSurfacePrivate::display):
(WebCore::GraphicsSurfacePrivate::size):
(WebCore::GraphicsSurfacePrivate::findFBConfigWithAlpha):
(WebCore::GraphicsSurfacePrivate::clear):
(GraphicsSurfacePrivate):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r140341 r140342  
     12013-01-21  Viatcheslav Ostapenko  <sl.ostapenko@samsung.com>
     2
     3        [EFL][Qt][WebGl] Random crash in GraphicsContext3D::drawArrays
     4        https://bugs.webkit.org/show_bug.cgi?id=107178
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        Workaround for the problem in mesa when internal llvm pipe object is deleted
     9        later than the screen object. Screen object is deleted because the corresponding
     10        X server display connection closed.
     11        Keep X server display connection open until program shutdown.
     12        OffScreenRootWindow::display is now static, so there is no need to create
     13        OffScreenRootWindow object on client side.
     14
     15        Fixes crash that appears during run of fast/canavs/webgl tests.
     16
     17        * platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp:
     18        (OffScreenRootWindow):
     19        (WebCore::OffScreenRootWindow::DisplayConnection::DisplayConnection):
     20        (DisplayConnection):
     21        (WebCore::OffScreenRootWindow::DisplayConnection::~DisplayConnection):
     22        (WebCore::OffScreenRootWindow::DisplayConnection::display):
     23        (WebCore::OffScreenRootWindow::display):
     24        (WebCore::OffScreenRootWindow::~OffScreenRootWindow):
     25        (WebCore):
     26        (WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
     27        (WebCore::GraphicsSurfacePrivate::createSurface):
     28        (WebCore::GraphicsSurfacePrivate::createPixmap):
     29        (WebCore::GraphicsSurfacePrivate::makeCurrent):
     30        (WebCore::GraphicsSurfacePrivate::doneCurrent):
     31        (WebCore::GraphicsSurfacePrivate::swapBuffers):
     32        (WebCore::GraphicsSurfacePrivate::display):
     33        (WebCore::GraphicsSurfacePrivate::size):
     34        (WebCore::GraphicsSurfacePrivate::findFBConfigWithAlpha):
     35        (WebCore::GraphicsSurfacePrivate::clear):
     36        (GraphicsSurfacePrivate):
     37
    1382013-01-21  Michael[tm] Smith  <mike@w3.org>
    239
  • trunk/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp

    r140252 r140342  
    145145    }
    146146
    147     Display* display()
    148     {
    149         if (!m_display)
     147private:
     148    struct DisplayConnection {
     149        DisplayConnection()
     150        {
    150151            m_display = XOpenDisplay(0);
    151         return m_display;
     152        }
     153
     154        ~DisplayConnection()
     155        {
     156            XCloseDisplay(m_display);
     157        }
     158
     159        Display* display() { return m_display; }
     160    private:
     161        Display* m_display;
     162    };
     163
     164public:
     165    static Display* display()
     166    {
     167        // Display connection will only be broken at program shutdown.
     168        static DisplayConnection displayConnection;
     169        return displayConnection.display();
    152170    }
    153171
    154172    ~OffScreenRootWindow()
    155173    {
    156         if (--m_refCount || !m_display)
     174        if (--m_refCount)
    157175            return;
    158176
    159177        if (m_window) {
    160             XUnmapWindow(m_display, m_window);
    161             XDestroyWindow(m_display, m_window);
     178            XUnmapWindow(display(), m_window);
     179            XDestroyWindow(display(), m_window);
    162180            m_window = 0;
    163181        }
    164 
    165         XCloseDisplay(m_display);
    166         m_display = 0;
    167182    }
    168183
     
    170185    static int m_refCount;
    171186    static Window m_window;
    172     static Display* m_display;
    173187};
    174188
    175189int OffScreenRootWindow::m_refCount = 0;
    176190Window OffScreenRootWindow::m_window = 0;
    177 Display* OffScreenRootWindow::m_display = 0;
    178191
    179192static const int glxSpec[] = {
     
    196209struct GraphicsSurfacePrivate {
    197210    GraphicsSurfacePrivate(const PlatformGraphicsContext3D shareContext = 0)
    198         : m_display(m_offScreenWindow.display())
     211        : m_offScreenWindow(adoptPtr(new OffScreenRootWindow()))
    199212        , m_xPixmap(0)
    200213        , m_glxPixmap(0)
     
    223236
    224237        int numReturned;
    225         GLXFBConfig* fbConfigs = glXChooseFBConfig(m_display, DefaultScreen(m_display), attributes, &numReturned);
     238        GLXFBConfig* fbConfigs = glXChooseFBConfig(display(), DefaultScreen(display()), attributes, &numReturned);
    226239
    227240        // Make sure that we choose a configuration that supports an alpha mask.
     
    231244
    232245        // Create a GLX context for OpenGL rendering
    233         m_glContext = glXCreateNewContext(m_display, m_fbConfig, GLX_RGBA_TYPE, shareContextObject, true);
     246        m_glContext = glXCreateNewContext(display(), m_fbConfig, GLX_RGBA_TYPE, shareContextObject, true);
    234247    }
    235248
    236249    GraphicsSurfacePrivate(uint32_t winId)
    237         : m_display(m_offScreenWindow.display())
    238         , m_xPixmap(0)
     250        : m_xPixmap(0)
    239251        , m_glxPixmap(0)
    240252        , m_surface(winId)
     
    256268    uint32_t createSurface(const IntSize& size)
    257269    {
    258         XVisualInfo* visualInfo = glXGetVisualFromFBConfig(m_display, m_fbConfig);
     270        XVisualInfo* visualInfo = glXGetVisualFromFBConfig(display(), m_fbConfig);
    259271        if (!visualInfo)
    260272            return 0;
    261273
    262         Colormap cmap = XCreateColormap(m_display, m_offScreenWindow.getXWindow(), visualInfo->visual, AllocNone);
     274        Colormap cmap = XCreateColormap(display(), m_offScreenWindow->getXWindow(), visualInfo->visual, AllocNone);
    263275
    264276        XSetWindowAttributes a;
    265         a.background_pixel = WhitePixel(m_display, 0);
    266         a.border_pixel = BlackPixel(m_display, 0);
     277        a.background_pixel = WhitePixel(display(), 0);
     278        a.border_pixel = BlackPixel(display(), 0);
    267279        a.colormap = cmap;
    268         m_surface = XCreateWindow(m_display, m_offScreenWindow.getXWindow(), 0, 0, size.width(), size.height(),
     280        m_surface = XCreateWindow(display(), m_offScreenWindow->getXWindow(), 0, 0, size.width(), size.height(),
    269281            0, visualInfo->depth, InputOutput, visualInfo->visual,
    270282            CWBackPixel | CWBorderPixel | CWColormap, &a);
    271         XSetWindowBackgroundPixmap(m_display, m_surface, 0);
    272         XCompositeRedirectWindow(m_display, m_surface, CompositeRedirectManual);
    273         m_glxSurface = glXCreateWindow(m_display, m_fbConfig, m_surface, 0);
     283        XSetWindowBackgroundPixmap(display(), m_surface, 0);
     284        XCompositeRedirectWindow(display(), m_surface, CompositeRedirectManual);
     285        m_glxSurface = glXCreateWindow(display(), m_fbConfig, m_surface, 0);
    274286        XFree(visualInfo);
    275287
    276288        // Make sure the XRender Extension is available.
    277289        int eventBasep, errorBasep;
    278         if (!XRenderQueryExtension(m_display, &eventBasep, &errorBasep))
     290        if (!XRenderQueryExtension(display(), &eventBasep, &errorBasep))
    279291            return 0;
    280292
    281         XMapWindow(m_display, m_surface);
     293        XMapWindow(display(), m_surface);
    282294        return m_surface;
    283295    }
     
    286298    {
    287299        XWindowAttributes attr;
    288         if (!XGetWindowAttributes(m_display, winId, &attr))
     300        if (!XGetWindowAttributes(display(), winId, &attr))
    289301            return;
    290302
     
    293305            return;
    294306
    295         ScopedXPixmapCreationErrorHandler handler(m_display);
     307        ScopedXPixmapCreationErrorHandler handler(display());
    296308        m_size = IntSize(attr.width, attr.height);
    297309
    298         XRenderPictFormat* format = XRenderFindVisualFormat(m_display, attr.visual);
     310        XRenderPictFormat* format = XRenderFindVisualFormat(display(), attr.visual);
    299311        m_hasAlpha = (format->type == PictTypeDirect && format->direct.alphaMask);
    300312
    301313        int numberOfConfigs;
    302         GLXFBConfig* configs = glXChooseFBConfig(m_display, XDefaultScreen(m_display), glxSpec, &numberOfConfigs);
     314        GLXFBConfig* configs = glXChooseFBConfig(display(), XDefaultScreen(display()), glxSpec, &numberOfConfigs);
    303315
    304316        // If origin window has alpha then find config with alpha.
    305317        GLXFBConfig& config = m_hasAlpha ? findFBConfigWithAlpha(configs, numberOfConfigs) : configs[0];
    306318
    307         m_xPixmap = XCompositeNameWindowPixmap(m_display, winId);
    308         m_glxPixmap = glXCreatePixmap(m_display, config, m_xPixmap, glxAttributes);
     319        m_xPixmap = XCompositeNameWindowPixmap(display(), winId);
     320        m_glxPixmap = glXCreatePixmap(display(), config, m_xPixmap, glxAttributes);
    309321
    310322        if (!handler.isValidOperation())
     
    312324        else {
    313325            uint inverted = 0;
    314             glXQueryDrawable(m_display, m_glxPixmap, GLX_Y_INVERTED_EXT, &inverted);
     326            glXQueryDrawable(display(), m_glxPixmap, GLX_Y_INVERTED_EXT, &inverted);
    315327            m_textureIsYInverted = !!inverted;
    316328        }
     
    329341        m_detachedSurface = glXGetCurrentDrawable();
    330342        if (m_surface && m_glContext)
    331             glXMakeCurrent(m_display, m_surface, m_glContext);
     343            glXMakeCurrent(display(), m_surface, m_glContext);
    332344    }
    333345
     
    335347    {
    336348        if (m_detachedContext)
    337             glXMakeCurrent(m_display, m_detachedSurface, m_detachedContext);
     349            glXMakeCurrent(display(), m_detachedSurface, m_detachedContext);
    338350        m_detachedContext = 0;
    339351    }
     
    352364            glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFBO);
    353365            pGlBindFramebuffer(GL_FRAMEBUFFER, 0);
    354             glXSwapBuffers(m_display, m_surface);
     366            glXSwapBuffers(display(), m_surface);
    355367            pGlBindFramebuffer(GL_FRAMEBUFFER, oldFBO);
    356368        }
     
    389401    }
    390402
    391     Display* display() const { return m_display; }
     403    Display* display() const { return OffScreenRootWindow::display(); }
    392404
    393405    GLXPixmap glxPixmap() const
     
    402414        if (m_size.isEmpty()) {
    403415            XWindowAttributes attr;
    404             if (XGetWindowAttributes(m_display, m_surface, &attr))
     416            if (XGetWindowAttributes(display(), m_surface, &attr))
    405417                const_cast<GraphicsSurfacePrivate*>(this)->m_size = IntSize(attr.width, attr.height);
    406418        }
     
    413425    {
    414426        for (int i = 0; i < numberOfConfigs; ++i) {
    415             XVisualInfo* visualInfo = glXGetVisualFromFBConfig(m_display, fbConfigs[i]);
     427            XVisualInfo* visualInfo = glXGetVisualFromFBConfig(display(), fbConfigs[i]);
    416428            if (!visualInfo)
    417429                continue;
    418430
    419             XRenderPictFormat* format = XRenderFindVisualFormat(m_display, visualInfo->visual);
     431            XRenderPictFormat* format = XRenderFindVisualFormat(display(), visualInfo->visual);
    420432            XFree(visualInfo);
    421433
     
    431443    {
    432444        if (m_glxPixmap) {
    433             glXDestroyPixmap(m_display, m_glxPixmap);
     445            glXDestroyPixmap(display(), m_glxPixmap);
    434446            m_glxPixmap = 0;
    435447        }
    436448
    437449        if (m_xPixmap) {
    438             XFreePixmap(m_display, m_xPixmap);
     450            XFreePixmap(display(), m_xPixmap);
    439451            m_xPixmap = 0;
    440452        }
     
    442454        // Client doesn't own the window. Delete surface only on writing side.
    443455        if (!m_isReceiver && m_surface) {
    444             XDestroyWindow(m_display, m_surface);
     456            XDestroyWindow(display(), m_surface);
    445457            m_surface = 0;
    446458        }
    447459
    448460        if (m_glContext) {
    449             glXDestroyContext(m_display, m_glContext);
     461            glXDestroyContext(display(), m_glContext);
    450462            m_glContext = 0;
    451463        }
    452464    }
    453465
    454     OffScreenRootWindow m_offScreenWindow;
     466    OwnPtr<OffScreenRootWindow> m_offScreenWindow;
    455467    IntSize m_size;
    456     Display* m_display;
    457468    Pixmap m_xPixmap;
    458469    GLXPixmap m_glxPixmap;
Note: See TracChangeset for help on using the changeset viewer.