⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 274354 in webkit


Ignore:
Timestamp:
Mar 12, 2021, 7:02:28 AM (6 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] GTK4 crashes with XVFB: GLXBadWindow
https://bugs.webkit.org/show_bug.cgi?id=223108

Reviewed by Žan Doberšek.

Source/WebCore:

  • platform/graphics/x11/PlatformDisplayX11.cpp:

(WebCore::PlatformDisplayX11::supportsGLX const): Check if GLX extension is supported and return the base error code.

  • platform/graphics/x11/PlatformDisplayX11.h:

Source/WebKit:

Handle GLXBadWindow errors in AcceleratedBackingStoreX11.

  • UIProcess/gtk/AcceleratedBackingStoreX11.cpp:

(WebKit::AcceleratedBackingStoreX11::checkRequirements):
(WebKit::glxErrorCode):
(WebKit::AcceleratedBackingStoreX11::~AcceleratedBackingStoreX11):
(WebKit::AcceleratedBackingStoreX11::update):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r274353 r274354  
     12021-03-12  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] GTK4 crashes with XVFB: GLXBadWindow
     4        https://bugs.webkit.org/show_bug.cgi?id=223108
     5
     6        Reviewed by Žan Doberšek.
     7
     8        * platform/graphics/x11/PlatformDisplayX11.cpp:
     9        (WebCore::PlatformDisplayX11::supportsGLX const): Check if GLX extension is supported and return the base error code.
     10        * platform/graphics/x11/PlatformDisplayX11.h:
     11
    1122021-03-12  Antoine Quint  <graouts@webkit.org>
    213
  • trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp

    r274273 r274354  
    4343#endif
    4444
     45#if USE(GLX)
     46#include <GL/glx.h>
     47#endif
     48
    4549#if USE(LCMS)
    4650#include <lcms2.h>
     
    129133    damageErrorBase = m_damageErrorBase;
    130134    return m_supportsXDamage.value();
     135}
     136
     137bool PlatformDisplayX11::supportsGLX(Optional<int>& glxErrorBase) const
     138{
     139#if USE(GLX)
     140    if (!m_supportsGLX) {
     141        m_supportsGLX = false;
     142        if (m_display) {
     143            int eventBase, errorBase;
     144            m_supportsGLX = glXQueryExtension(m_display, &errorBase, &eventBase);
     145            if (m_supportsGLX.value())
     146                m_glxErrorBase = errorBase;
     147        }
     148    }
     149
     150    glxErrorBase = m_glxErrorBase;
     151    return m_supportsGLX.value();
     152#else
     153    return false;
     154#endif
    131155}
    132156
  • trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h

    r274273 r274354  
    5050    bool supportsXComposite() const;
    5151    bool supportsXDamage(Optional<int>& damageEventBase, Optional<int>& damageErrorBase) const;
     52    bool supportsGLX(Optional<int>& glxErrorBase) const;
    5253
    5354private:
     
    6970    mutable Optional<int> m_damageEventBase;
    7071    mutable Optional<int> m_damageErrorBase;
     72#if USE(GLX)
     73    mutable Optional<bool> m_supportsGLX;
     74    mutable Optional<int> m_glxErrorBase;
     75#endif
    7176    mutable void* m_visual { nullptr };
    7277};
  • trunk/Source/WebKit/ChangeLog

    r274330 r274354  
     12021-03-12  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] GTK4 crashes with XVFB: GLXBadWindow
     4        https://bugs.webkit.org/show_bug.cgi?id=223108
     5
     6        Reviewed by Žan Doberšek.
     7
     8        Handle GLXBadWindow errors in AcceleratedBackingStoreX11.
     9
     10        * UIProcess/gtk/AcceleratedBackingStoreX11.cpp:
     11        (WebKit::AcceleratedBackingStoreX11::checkRequirements):
     12        (WebKit::glxErrorCode):
     13        (WebKit::AcceleratedBackingStoreX11::~AcceleratedBackingStoreX11):
     14        (WebKit::AcceleratedBackingStoreX11::update):
     15
    1162021-03-12  Carlos Garcia Campos  <cgarcia@igalia.com>
    217
  • trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreX11.cpp

    r267398 r274354  
    4747#include <wtf/NeverDestroyed.h>
    4848
     49#if USE(GLX)
     50#include <X11/Xproto.h>
     51#include <GL/glxproto.h>
     52#endif
     53
    4954namespace WebKit {
    5055
    5156static Optional<int> s_damageEventBase;
    5257static Optional<int> s_damageErrorBase;
     58#if USE(GLX)
     59static Optional<int> s_glxErrorBase;
     60#endif
    5361
    5462class XDamageNotifier {
     
    136144{
    137145    auto& display = downcast<WebCore::PlatformDisplayX11>(WebCore::PlatformDisplay::sharedDisplay());
     146#if USE(GLX)
     147    // GLX is optional, he we just want the error base.
     148    display.supportsGLX(s_glxErrorBase);
     149#endif
    138150    return display.supportsXComposite() && display.supportsXDamage(s_damageEventBase, s_damageErrorBase);
    139151}
     
    156168}
    157169
     170#if USE(GLX)
     171static inline unsigned char glxErrorCode(unsigned char errorCode)
     172{
     173    ASSERT(s_glxErrorBase);
     174    return static_cast<unsigned>(s_glxErrorBase.value()) + errorCode;
     175}
     176#endif
     177
    158178AcceleratedBackingStoreX11::~AcceleratedBackingStoreX11()
    159179{
     
    162182
    163183    Display* display = downcast<WebCore::PlatformDisplayX11>(WebCore::PlatformDisplay::sharedDisplay()).native();
    164     WebCore::XErrorTrapper trapper(display, WebCore::XErrorTrapper::Policy::Crash, { BadDrawable, xDamageErrorCode(BadDamage) });
     184    Vector<unsigned char> errorList = { BadDrawable, xDamageErrorCode(BadDamage) };
     185#if USE(GLX)
     186    if (s_glxErrorBase)
     187        errorList.append(glxErrorCode(GLXBadWindow));
     188#endif
     189    WebCore::XErrorTrapper trapper(display, WebCore::XErrorTrapper::Policy::Crash, WTFMove(errorList));
    165190    if (m_damage) {
    166191        XDamageNotifier::singleton().remove(m_damage.get());
     
    179204
    180205    if (m_surface) {
    181         WebCore::XErrorTrapper trapper(display, WebCore::XErrorTrapper::Policy::Crash, { BadDrawable, xDamageErrorCode(BadDamage) });
     206        Vector<unsigned char> errorList = { BadDrawable, xDamageErrorCode(BadDamage) };
     207#if USE(GLX)
     208        if (s_glxErrorBase)
     209            errorList.append(glxErrorCode(GLXBadWindow));
     210#endif
     211        WebCore::XErrorTrapper trapper(display, WebCore::XErrorTrapper::Policy::Crash, WTFMove(errorList));
    182212        if (m_damage) {
    183213            XDamageNotifier::singleton().remove(m_damage.get());
     
    199229    size.scale(deviceScaleFactor);
    200230
    201     WebCore::XErrorTrapper trapper(display, WebCore::XErrorTrapper::Policy::Crash, { BadDrawable, xDamageErrorCode(BadDamage) });
     231    Vector<unsigned char> errorList = { BadDrawable, xDamageErrorCode(BadDamage) };
     232#if USE(GLX)
     233    if (s_glxErrorBase)
     234        errorList.append(glxErrorCode(GLXBadWindow));
     235#endif
     236    WebCore::XErrorTrapper trapper(display, WebCore::XErrorTrapper::Policy::Crash, WTFMove(errorList));
    202237    ASSERT(downcast<WebCore::PlatformDisplayX11>(WebCore::PlatformDisplay::sharedDisplay()).native() == gdk_x11_display_get_xdisplay(gdk_display_get_default()));
    203238#if USE(GTK4)
Note: See TracChangeset for help on using the changeset viewer.