Skip to content
Permalink
Browse files
[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):

Canonical link: https://commits.webkit.org/235223@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274354 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
carlosgcampos committed Mar 12, 2021
1 parent 4449248 commit b8e7f4efaf2c16b154dde3ee3e64ad6402c55c7f
Showing 5 changed files with 93 additions and 3 deletions.
@@ -1,3 +1,14 @@
2021-03-12 Carlos Garcia Campos <cgarcia@igalia.com>

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

Reviewed by Žan Doberšek.

* 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:

2021-03-12 Antoine Quint <graouts@webkit.org>

Blending lengths of different types should be allowed outside of the [0-1] range
@@ -42,6 +42,10 @@
#include <EGL/eglext.h>
#endif

#if USE(GLX)
#include <GL/glx.h>
#endif

#if USE(LCMS)
#include <lcms2.h>
#endif
@@ -130,6 +134,26 @@ bool PlatformDisplayX11::supportsXDamage(Optional<int>& damageEventBase, Optiona
return m_supportsXDamage.value();
}

bool PlatformDisplayX11::supportsGLX(Optional<int>& glxErrorBase) const
{
#if USE(GLX)
if (!m_supportsGLX) {
m_supportsGLX = false;
if (m_display) {
int eventBase, errorBase;
m_supportsGLX = glXQueryExtension(m_display, &errorBase, &eventBase);
if (m_supportsGLX.value())
m_glxErrorBase = errorBase;
}
}

glxErrorBase = m_glxErrorBase;
return m_supportsGLX.value();
#else
return false;
#endif
}

void* PlatformDisplayX11::visual() const
{
if (m_visual)
@@ -49,6 +49,7 @@ class PlatformDisplayX11 final : public PlatformDisplay {
void* visual() const;
bool supportsXComposite() const;
bool supportsXDamage(Optional<int>& damageEventBase, Optional<int>& damageErrorBase) const;
bool supportsGLX(Optional<int>& glxErrorBase) const;

private:
PlatformDisplayX11(::Display*, NativeDisplayOwned);
@@ -68,6 +69,10 @@ class PlatformDisplayX11 final : public PlatformDisplay {
mutable Optional<bool> m_supportsXDamage;
mutable Optional<int> m_damageEventBase;
mutable Optional<int> m_damageErrorBase;
#if USE(GLX)
mutable Optional<bool> m_supportsGLX;
mutable Optional<int> m_glxErrorBase;
#endif
mutable void* m_visual { nullptr };
};

@@ -1,3 +1,18 @@
2021-03-12 Carlos Garcia Campos <cgarcia@igalia.com>

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

Reviewed by Žan Doberšek.

Handle GLXBadWindow errors in AcceleratedBackingStoreX11.

* UIProcess/gtk/AcceleratedBackingStoreX11.cpp:
(WebKit::AcceleratedBackingStoreX11::checkRequirements):
(WebKit::glxErrorCode):
(WebKit::AcceleratedBackingStoreX11::~AcceleratedBackingStoreX11):
(WebKit::AcceleratedBackingStoreX11::update):

2021-03-12 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] Bump API version when building with libsoup3
@@ -46,10 +46,18 @@
#include <wtf/HashMap.h>
#include <wtf/NeverDestroyed.h>

#if USE(GLX)
#include <X11/Xproto.h>
#include <GL/glxproto.h>
#endif

namespace WebKit {

static Optional<int> s_damageEventBase;
static Optional<int> s_damageErrorBase;
#if USE(GLX)
static Optional<int> s_glxErrorBase;
#endif

class XDamageNotifier {
WTF_MAKE_NONCOPYABLE(XDamageNotifier);
@@ -135,6 +143,10 @@ class XDamageNotifier {
bool AcceleratedBackingStoreX11::checkRequirements()
{
auto& display = downcast<WebCore::PlatformDisplayX11>(WebCore::PlatformDisplay::sharedDisplay());
#if USE(GLX)
// GLX is optional, he we just want the error base.
display.supportsGLX(s_glxErrorBase);
#endif
return display.supportsXComposite() && display.supportsXDamage(s_damageEventBase, s_damageErrorBase);
}

@@ -155,13 +167,26 @@ static inline unsigned char xDamageErrorCode(unsigned char errorCode)
return static_cast<unsigned>(s_damageErrorBase.value()) + errorCode;
}

#if USE(GLX)
static inline unsigned char glxErrorCode(unsigned char errorCode)
{
ASSERT(s_glxErrorBase);
return static_cast<unsigned>(s_glxErrorBase.value()) + errorCode;
}
#endif

AcceleratedBackingStoreX11::~AcceleratedBackingStoreX11()
{
if (!m_surface && !m_damage)
return;

Display* display = downcast<WebCore::PlatformDisplayX11>(WebCore::PlatformDisplay::sharedDisplay()).native();
WebCore::XErrorTrapper trapper(display, WebCore::XErrorTrapper::Policy::Crash, { BadDrawable, xDamageErrorCode(BadDamage) });
Vector<unsigned char> errorList = { BadDrawable, xDamageErrorCode(BadDamage) };
#if USE(GLX)
if (s_glxErrorBase)
errorList.append(glxErrorCode(GLXBadWindow));
#endif
WebCore::XErrorTrapper trapper(display, WebCore::XErrorTrapper::Policy::Crash, WTFMove(errorList));
if (m_damage) {
XDamageNotifier::singleton().remove(m_damage.get());
m_damage.reset();
@@ -178,7 +203,12 @@ void AcceleratedBackingStoreX11::update(const LayerTreeContext& layerTreeContext
Display* display = downcast<WebCore::PlatformDisplayX11>(WebCore::PlatformDisplay::sharedDisplay()).native();

if (m_surface) {
WebCore::XErrorTrapper trapper(display, WebCore::XErrorTrapper::Policy::Crash, { BadDrawable, xDamageErrorCode(BadDamage) });
Vector<unsigned char> errorList = { BadDrawable, xDamageErrorCode(BadDamage) };
#if USE(GLX)
if (s_glxErrorBase)
errorList.append(glxErrorCode(GLXBadWindow));
#endif
WebCore::XErrorTrapper trapper(display, WebCore::XErrorTrapper::Policy::Crash, WTFMove(errorList));
if (m_damage) {
XDamageNotifier::singleton().remove(m_damage.get());
m_damage.reset();
@@ -198,7 +228,12 @@ void AcceleratedBackingStoreX11::update(const LayerTreeContext& layerTreeContext
float deviceScaleFactor = m_webPage.deviceScaleFactor();
size.scale(deviceScaleFactor);

WebCore::XErrorTrapper trapper(display, WebCore::XErrorTrapper::Policy::Crash, { BadDrawable, xDamageErrorCode(BadDamage) });
Vector<unsigned char> errorList = { BadDrawable, xDamageErrorCode(BadDamage) };
#if USE(GLX)
if (s_glxErrorBase)
errorList.append(glxErrorCode(GLXBadWindow));
#endif
WebCore::XErrorTrapper trapper(display, WebCore::XErrorTrapper::Policy::Crash, WTFMove(errorList));
ASSERT(downcast<WebCore::PlatformDisplayX11>(WebCore::PlatformDisplay::sharedDisplay()).native() == gdk_x11_display_get_xdisplay(gdk_display_get_default()));
#if USE(GTK4)
auto* visual = WK_XVISUAL(downcast<WebCore::PlatformDisplayX11>(WebCore::PlatformDisplay::sharedDisplay()));

0 comments on commit b8e7f4e

Please sign in to comment.