Diff
Modified: trunk/Source/WebCore/ChangeLog (292210 => 292211)
--- trunk/Source/WebCore/ChangeLog 2022-04-01 08:29:51 UTC (rev 292210)
+++ trunk/Source/WebCore/ChangeLog 2022-04-01 09:00:32 UTC (rev 292211)
@@ -1,5 +1,45 @@
2022-04-01 Carlos Garcia Campos <cgar...@igalia.com>
+ REGRESSION(r290360): [GLX] Crash on process exit
+ https://bugs.webkit.org/show_bug.cgi?id=238494
+
+ Reviewed by Michael Catanzaro.
+
+ When creating a PlatformDisplay from a shared GdkDisplay, we need to keep a reference to the display and connect
+ to closed signal to release our display dependent resources. Closed signal is emitted right before the native
+ display is actually closed by GDK. We also need to make sure that the sharing GL context is released before the
+ PlatformDisplay is destroyed. This is always happening for EGL because the sharing GL context is cleared before
+ terminating the EGL display in the atexit handler, but that's not the case of GLX. Since X11 only allows one
+ PlatformDisplay, which is always the shared one, we can just install an atexit handler in the constructor to
+ clear the sharing context before the destructor is called.
+
+ * platform/graphics/PlatformDisplay.cpp:
+ (WebCore::PlatformDisplay::createPlatformDisplay):
+ (WebCore::PlatformDisplay::PlatformDisplay):
+ (WebCore::PlatformDisplay::sharedDisplayDidClose):
+ (WebCore::PlatformDisplay::~PlatformDisplay):
+ (WebCore::PlatformDisplay::clearSharingGLContext):
+ (WebCore::PlatformDisplay::terminateEGLDisplay):
+ * platform/graphics/PlatformDisplay.h:
+ * platform/graphics/libwpe/PlatformDisplayLibWPE.cpp:
+ (WebCore::PlatformDisplayLibWPE::PlatformDisplayLibWPE):
+ * platform/graphics/wayland/PlatformDisplayWayland.cpp:
+ (WebCore::PlatformDisplayWayland::create):
+ (WebCore::PlatformDisplayWayland::PlatformDisplayWayland):
+ (WebCore::PlatformDisplayWayland::~PlatformDisplayWayland):
+ (WebCore::PlatformDisplayWayland::sharedDisplayDidClose):
+ * platform/graphics/wayland/PlatformDisplayWayland.h:
+ * platform/graphics/win/PlatformDisplayWin.h:
+ * platform/graphics/x11/PlatformDisplayX11.cpp:
+ (WebCore::PlatformDisplayX11::create):
+ (WebCore::clearSharingGLContextAtExit):
+ (WebCore::PlatformDisplayX11::PlatformDisplayX11):
+ (WebCore::PlatformDisplayX11::~PlatformDisplayX11):
+ (WebCore::PlatformDisplayX11::sharedDisplayDidClose):
+ * platform/graphics/x11/PlatformDisplayX11.h:
+
+2022-04-01 Carlos Garcia Campos <cgar...@igalia.com>
+
Add support for element.computedStyleMap()
https://bugs.webkit.org/show_bug.cgi?id=238375
Modified: trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp (292210 => 292211)
--- trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp 2022-04-01 08:29:51 UTC (rev 292210)
+++ trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp 2022-04-01 09:00:32 UTC (rev 292211)
@@ -96,25 +96,14 @@
if (gtk_init_check(nullptr, nullptr)) {
GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
#if PLATFORM(X11)
- if (GDK_IS_X11_DISPLAY(display)) {
- auto platformDisplay = PlatformDisplayX11::create(GDK_DISPLAY_XDISPLAY(display));
-#if USE(ATSPI) && USE(GTK4)
- if (const char* atspiBusAddress = static_cast<const char*>(g_object_get_data(G_OBJECT(display), "-gtk-atspi-bus-address")))
- platformDisplay->m_accessibilityBusAddress = String::fromUTF8(atspiBusAddress);
+ if (GDK_IS_X11_DISPLAY(display))
+ return PlatformDisplayX11::create(display);
#endif
- return platformDisplay;
- }
-#endif
+
#if PLATFORM(WAYLAND)
- if (GDK_IS_WAYLAND_DISPLAY(display)) {
- auto platformDisplay = PlatformDisplayWayland::create(gdk_wayland_display_get_wl_display(display));
-#if USE(ATSPI) && USE(GTK4)
- if (const char* atspiBusAddress = static_cast<const char*>(g_object_get_data(G_OBJECT(display), "-gtk-atspi-bus-address")))
- platformDisplay->m_accessibilityBusAddress = String::fromUTF8(atspiBusAddress);
+ if (GDK_IS_WAYLAND_DISPLAY(display))
+ return PlatformDisplayWayland::create(display);
#endif
- return platformDisplay;
- }
-#endif
}
#endif // PLATFORM(GTK)
@@ -174,19 +163,45 @@
s_sharedDisplayForCompositing = &display;
}
-PlatformDisplay::PlatformDisplay(NativeDisplayOwned displayOwned)
- : m_nativeDisplayOwned(displayOwned)
+PlatformDisplay::PlatformDisplay()
#if USE(EGL)
- , m_eglDisplay(EGL_NO_DISPLAY)
+ : m_eglDisplay(EGL_NO_DISPLAY)
#endif
{
}
+#if PLATFORM(GTK)
+PlatformDisplay::PlatformDisplay(GdkDisplay* display)
+ : m_sharedDisplay(display)
+{
+#if USE(ATSPI) && USE(GTK4)
+ if (const char* atspiBusAddress = static_cast<const char*>(g_object_get_data(G_OBJECT(display), "-gtk-atspi-bus-address")))
+ m_accessibilityBusAddress = String::fromUTF8(atspiBusAddress);
+#endif
+
+ g_signal_connect(m_sharedDisplay.get(), "closed", G_CALLBACK(+[](GdkDisplay*, gboolean, gpointer userData) {
+ auto& platformDisplay = *static_cast<PlatformDisplay*>(userData);
+ platformDisplay.sharedDisplayDidClose();
+ }), this);
+}
+
+void PlatformDisplay::sharedDisplayDidClose()
+{
+#if USE(EGL) || USE(GLX)
+ clearSharingGLContext();
+#endif
+}
+#endif
+
PlatformDisplay::~PlatformDisplay()
{
#if USE(EGL) && !PLATFORM(WIN)
ASSERT(m_eglDisplay == EGL_NO_DISPLAY);
#endif
+#if PLATFORM(GTK)
+ if (m_sharedDisplay)
+ g_signal_handlers_disconnect_by_data(m_sharedDisplay.get(), this);
+#endif
if (s_sharedDisplayForCompositing == this)
s_sharedDisplayForCompositing = nullptr;
}
@@ -198,6 +213,11 @@
m_sharingGLContext = GLContext::createSharingContext(*this);
return m_sharingGLContext.get();
}
+
+void PlatformDisplay::clearSharingGLContext()
+{
+ m_sharingGLContext = nullptr;
+}
#endif
#if USE(EGL)
@@ -274,7 +294,7 @@
m_gstGLDisplay = nullptr;
m_gstGLContext = nullptr;
#endif
- m_sharingGLContext = nullptr;
+ clearSharingGLContext();
ASSERT(m_eglDisplayInitialized);
if (m_eglDisplay == EGL_NO_DISPLAY)
return;
Modified: trunk/Source/WebCore/platform/graphics/PlatformDisplay.h (292210 => 292211)
--- trunk/Source/WebCore/platform/graphics/PlatformDisplay.h 2022-04-01 08:29:51 UTC (rev 292210)
+++ trunk/Source/WebCore/platform/graphics/PlatformDisplay.h 2022-04-01 09:00:32 UTC (rev 292211)
@@ -33,6 +33,12 @@
typedef void *EGLDisplay;
#endif
+#if PLATFORM(GTK)
+#include <wtf/glib/GRefPtr.h>
+
+typedef struct _GdkDisplay GdkDisplay;
+#endif
+
#if ENABLE(VIDEO) && USE(GSTREAMER_GL)
#include "GRefPtrGStreamer.h"
@@ -74,6 +80,7 @@
#if USE(EGL) || USE(GLX)
WEBCORE_EXPORT GLContext* sharingGLContext();
+ void clearSharingGLContext();
#endif
#if USE(EGL)
@@ -96,13 +103,19 @@
#endif
protected:
- enum class NativeDisplayOwned { No, Yes };
- explicit PlatformDisplay(NativeDisplayOwned);
+ PlatformDisplay();
+#if PLATFORM(GTK)
+ explicit PlatformDisplay(GdkDisplay*);
+#endif
static void setSharedDisplayForCompositing(PlatformDisplay&);
- NativeDisplayOwned m_nativeDisplayOwned { NativeDisplayOwned::No };
+#if PLATFORM(GTK)
+ virtual void sharedDisplayDidClose();
+ GRefPtr<GdkDisplay> m_sharedDisplay;
+#endif
+
#if USE(EGL)
virtual void initializeEGLDisplay();
Modified: trunk/Source/WebCore/platform/graphics/libwpe/PlatformDisplayLibWPE.cpp (292210 => 292211)
--- trunk/Source/WebCore/platform/graphics/libwpe/PlatformDisplayLibWPE.cpp 2022-04-01 08:29:51 UTC (rev 292210)
+++ trunk/Source/WebCore/platform/graphics/libwpe/PlatformDisplayLibWPE.cpp 2022-04-01 09:00:32 UTC (rev 292211)
@@ -59,7 +59,6 @@
}
PlatformDisplayLibWPE::PlatformDisplayLibWPE()
- : PlatformDisplay(NativeDisplayOwned::No)
{
#if PLATFORM(GTK)
PlatformDisplay::setSharedDisplayForCompositing(*this);
Modified: trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp (292210 => 292211)
--- trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp 2022-04-01 08:29:51 UTC (rev 292210)
+++ trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp 2022-04-01 09:00:32 UTC (rev 292211)
@@ -37,6 +37,14 @@
#include <EGL/eglext.h>
#include <wtf/Assertions.h>
+#if PLATFORM(GTK)
+#if USE(GTK4)
+#include <gdk/wayland/gdkwayland.h>
+#else
+#include <gdk/gdkwayland.h>
+#endif
+#endif
+
namespace WebCore {
const struct wl_registry_listener PlatformDisplayWayland::s_registryListener = {
@@ -56,27 +64,42 @@
if (!display)
return nullptr;
- auto platformDisplay = std::unique_ptr<PlatformDisplayWayland>(new PlatformDisplayWayland(display, NativeDisplayOwned::Yes));
+ auto platformDisplay = std::unique_ptr<PlatformDisplayWayland>(new PlatformDisplayWayland(display));
platformDisplay->initialize();
return platformDisplay;
}
-std::unique_ptr<PlatformDisplay> PlatformDisplayWayland::create(struct wl_display* display)
+#if PLATFORM(GTK)
+std::unique_ptr<PlatformDisplay> PlatformDisplayWayland::create(GdkDisplay* display)
{
- auto platformDisplay = std::unique_ptr<PlatformDisplayWayland>(new PlatformDisplayWayland(display, NativeDisplayOwned::No));
+ auto platformDisplay = std::unique_ptr<PlatformDisplayWayland>(new PlatformDisplayWayland(display));
platformDisplay->initialize();
return platformDisplay;
}
+#endif
-PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* display, NativeDisplayOwned displayOwned)
- : PlatformDisplay(displayOwned)
- , m_display(display)
+PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* display)
+ : m_display(display)
{
}
+#if PLATFORM(GTK)
+PlatformDisplayWayland::PlatformDisplayWayland(GdkDisplay* display)
+ : PlatformDisplay(display)
+ , m_display(gdk_wayland_display_get_wl_display(display))
+{
+}
+#endif
+
PlatformDisplayWayland::~PlatformDisplayWayland()
{
- if (m_nativeDisplayOwned == NativeDisplayOwned::Yes) {
+#if PLATFORM(GTK)
+ bool nativeDisplayOwned = !m_sharedDisplay;
+#else
+ bool nativeDisplayOwned = true;
+#endif
+
+ if (nativeDisplayOwned) {
m_compositor = nullptr;
m_registry = nullptr;
wl_display_disconnect(m_display);
@@ -83,6 +106,14 @@
}
}
+#if PLATFORM(GTK)
+void PlatformDisplayWayland::sharedDisplayDidClose()
+{
+ PlatformDisplay::sharedDisplayDidClose();
+ m_display = nullptr;
+}
+#endif
+
void PlatformDisplayWayland::initialize()
{
if (!m_display)
Modified: trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h (292210 => 292211)
--- trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h 2022-04-01 08:29:51 UTC (rev 292210)
+++ trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h 2022-04-01 09:00:32 UTC (rev 292211)
@@ -23,8 +23,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef PlatformDisplayWayland_h
-#define PlatformDisplayWayland_h
+#pragma once
#if PLATFORM(WAYLAND)
@@ -37,7 +36,9 @@
class PlatformDisplayWayland : public PlatformDisplay {
public:
static std::unique_ptr<PlatformDisplay> create();
- static std::unique_ptr<PlatformDisplay> create(struct wl_display*);
+#if PLATFORM(GTK)
+ static std::unique_ptr<PlatformDisplay> create(GdkDisplay*);
+#endif
virtual ~PlatformDisplayWayland();
@@ -51,8 +52,13 @@
Type type() const final { return PlatformDisplay::Type::Wayland; }
protected:
- PlatformDisplayWayland(struct wl_display*, NativeDisplayOwned);
+ explicit PlatformDisplayWayland(struct wl_display*);
+#if PLATFORM(GTK)
+ explicit PlatformDisplayWayland(GdkDisplay*);
+ void sharedDisplayDidClose() override;
+#endif
+
void initialize();
virtual void registryGlobal(const char* interface, uint32_t name);
@@ -67,5 +73,3 @@
SPECIALIZE_TYPE_TRAITS_PLATFORM_DISPLAY(PlatformDisplayWayland, Wayland)
#endif // PLATFORM(WAYLAND)
-
-#endif // PlatformDisplayWayland_h
Modified: trunk/Source/WebCore/platform/graphics/win/PlatformDisplayWin.h (292210 => 292211)
--- trunk/Source/WebCore/platform/graphics/win/PlatformDisplayWin.h 2022-04-01 08:29:51 UTC (rev 292210)
+++ trunk/Source/WebCore/platform/graphics/win/PlatformDisplayWin.h 2022-04-01 09:00:32 UTC (rev 292211)
@@ -42,11 +42,6 @@
virtual ~PlatformDisplayWin() = default;
private:
- PlatformDisplayWin()
- : PlatformDisplay(NativeDisplayOwned::No)
- {
- }
-
Type type() const override { return PlatformDisplay::Type::Windows; }
void initializeEGLDisplay() final;
Modified: trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp (292210 => 292211)
--- trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp 2022-04-01 08:29:51 UTC (rev 292210)
+++ trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp 2022-04-01 09:00:32 UTC (rev 292211)
@@ -28,6 +28,7 @@
#include "GLContext.h"
#include "XErrorTrapper.h"
+#include <cstdlib>
#if PLATFORM(X11)
#include <X11/Xatom.h>
@@ -36,7 +37,12 @@
#if PLATFORM(GTK)
#include <X11/Xutil.h>
#include <X11/extensions/Xdamage.h>
+#if USE(GTK4)
+#include <gdk/x11/gdkx.h>
+#else
+#include <gdk/gdkx.h>
#endif
+#endif
#if USE(EGL)
#include <EGL/egl.h>
@@ -55,30 +61,70 @@
if (!display)
return nullptr;
- return std::unique_ptr<PlatformDisplayX11>(new PlatformDisplayX11(display, NativeDisplayOwned::Yes));
+ return std::unique_ptr<PlatformDisplayX11>(new PlatformDisplayX11(display));
}
-std::unique_ptr<PlatformDisplay> PlatformDisplayX11::create(Display* display)
+#if PLATFORM(GTK)
+std::unique_ptr<PlatformDisplay> PlatformDisplayX11::create(GdkDisplay* display)
{
- return std::unique_ptr<PlatformDisplayX11>(new PlatformDisplayX11(display, NativeDisplayOwned::No));
+ return std::unique_ptr<PlatformDisplayX11>(new PlatformDisplayX11(display));
}
+#endif
-PlatformDisplayX11::PlatformDisplayX11(Display* display, NativeDisplayOwned displayOwned)
- : PlatformDisplay(displayOwned)
- , m_display(display)
+static inline void clearSharingGLContextAtExit()
{
+#if USE(GLX)
+ // In X11 only one PlatformDisplay instance is allowed per process which is the sharedDisplay one.
+ // We install an atexit handler to clear the sharing GL context to ensure it's released before
+ // the constructor is called, because clearing the context in X11 requires to access PlatformDisplay::sharedDisplay()
+ // and calling it from its constructor causes issues in some systems. See https://bugs.webkit.org/show_bug.cgi?id=238494.
+ static std::once_flag onceKey;
+ std::call_once(onceKey, [] {
+ std::atexit([] {
+ PlatformDisplay::sharedDisplay().clearSharingGLContext();
+ });
+ });
+#endif
}
+PlatformDisplayX11::PlatformDisplayX11(Display* display)
+ : m_display(display)
+{
+ clearSharingGLContextAtExit();
+}
+
+#if PLATFORM(GTK)
+PlatformDisplayX11::PlatformDisplayX11(GdkDisplay* display)
+ : PlatformDisplay(display)
+ , m_display(GDK_DISPLAY_XDISPLAY(display))
+{
+ clearSharingGLContextAtExit();
+}
+#endif
+
PlatformDisplayX11::~PlatformDisplayX11()
{
#if USE(EGL) || USE(GLX)
- // Clear the sharing context before releasing the display.
- m_sharingGLContext = nullptr;
+ ASSERT(!m_sharingGLContext);
#endif
- if (m_nativeDisplayOwned == NativeDisplayOwned::Yes)
+
+#if PLATFORM(GTK)
+ bool nativeDisplayOwned = !m_sharedDisplay;
+#else
+ bool nativeDisplayOwned = true;
+#endif
+ if (nativeDisplayOwned)
XCloseDisplay(m_display);
}
+#if PLATFORM(GTK)
+void PlatformDisplayX11::sharedDisplayDidClose()
+{
+ PlatformDisplay::sharedDisplayDidClose();
+ m_display = nullptr;
+}
+#endif
+
#if USE(EGL)
void PlatformDisplayX11::initializeEGLDisplay()
{
Modified: trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h (292210 => 292211)
--- trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h 2022-04-01 08:29:51 UTC (rev 292210)
+++ trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h 2022-04-01 09:00:32 UTC (rev 292211)
@@ -41,7 +41,9 @@
class PlatformDisplayX11 final : public PlatformDisplay {
public:
static std::unique_ptr<PlatformDisplay> create();
- static std::unique_ptr<PlatformDisplay> create(::Display*);
+#if PLATFORM(GTK)
+ static std::unique_ptr<PlatformDisplay> create(GdkDisplay*);
+#endif
virtual ~PlatformDisplayX11();
@@ -52,8 +54,13 @@
bool supportsGLX(std::optional<int>& glxErrorBase) const;
private:
- PlatformDisplayX11(::Display*, NativeDisplayOwned);
+ explicit PlatformDisplayX11(::Display*);
+#if PLATFORM(GTK)
+ explicit PlatformDisplayX11(GdkDisplay*);
+ void sharedDisplayDidClose() override;
+#endif
+
Type type() const override { return PlatformDisplay::Type::X11; }
#if USE(EGL)
Modified: trunk/Source/WebKit/ChangeLog (292210 => 292211)
--- trunk/Source/WebKit/ChangeLog 2022-04-01 08:29:51 UTC (rev 292210)
+++ trunk/Source/WebKit/ChangeLog 2022-04-01 09:00:32 UTC (rev 292211)
@@ -1,3 +1,13 @@
+2022-04-01 Carlos Garcia Campos <cgar...@igalia.com>
+
+ REGRESSION(r290360): [GLX] Crash on process exit
+ https://bugs.webkit.org/show_bug.cgi?id=238494
+
+ Reviewed by Michael Catanzaro.
+
+ * WebProcess/gtk/WaylandCompositorDisplay.cpp:
+ (WebKit::WaylandCompositorDisplay::WaylandCompositorDisplay):
+
2022-04-01 Tim Horton <timothy_hor...@apple.com>
Translated applications cannot use remote methods with BOOL arguments
Modified: trunk/Source/WebKit/WebProcess/gtk/WaylandCompositorDisplay.cpp (292210 => 292211)
--- trunk/Source/WebKit/WebProcess/gtk/WaylandCompositorDisplay.cpp 2022-04-01 08:29:51 UTC (rev 292210)
+++ trunk/Source/WebKit/WebProcess/gtk/WaylandCompositorDisplay.cpp 2022-04-01 09:00:32 UTC (rev 292211)
@@ -63,7 +63,7 @@
}
WaylandCompositorDisplay::WaylandCompositorDisplay(struct wl_display* display)
- : PlatformDisplayWayland(display, NativeDisplayOwned::Yes)
+ : PlatformDisplayWayland(display)
{
PlatformDisplay::setSharedDisplayForCompositing(*this);
}