12016-11-24 Carlos Garcia Campos <cgarcia@igalia.com>
2
3 [GTK] Crash in WebCore::PlatformDisplayX11::supportsXComposite when running under Wayland
4 https://bugs.webkit.org/show_bug.cgi?id=164917
5
6 Reviewed by NOBODY (OOPS!).
7
8 WebKitGTK+ appplications are expected to call gtk_init(), because WebKitGTK+, like GTK+ itself, requires a
9 display to work. We currently fallback to create a X11 display when X11 is enabled in cases where GTK+ doesn't
10 have a default display (gtk_init() wasn't called or failed). That's why we end up creating an X11 display under
11 Wayland when both Wayland and X11 option are enabled. The code assumes X11 display creation will always work if
12 X11 is enabled, but that's not true now that we support also Wayland at runtime. So, we should try to get a
13 native display before creating the PlatformDisplay. Rendering will not work in any case when gtk_init() is not
14 called, but in most of the cases those applications are not actually going to render anything, so this way at
15 least we will not crash.
16
17 * platform/graphics/PlatformDisplay.cpp:
18 (WebCore::PlatformDisplay::createPlatformDisplay): Use create() method for X11 and Wayland if we couldn't get a
19 native display from GTK+. If everything fails create a display with no native.
20 (WebCore::PlatformDisplay::PlatformDisplay): Add NativeDisplayOwned parameter.
21 * platform/graphics/PlatformDisplay.h:
22 * platform/graphics/wayland/PlatformDisplayWayland.cpp:
23 (WebCore::PlatformDisplayWayland::create): Try to create a native Wayland display or return nullptr.
24 (WebCore::PlatformDisplayWayland::PlatformDisplayWayland): Initialize NativeDisplayOwned parameter.
25 (WebCore::PlatformDisplayWayland::~PlatformDisplayWayland): Destroy the display if owned.
26 (WebCore::PlatformDisplayWayland::initialize): Return early if native display is nullptr.
27 * platform/graphics/wayland/PlatformDisplayWayland.h:
28 * platform/graphics/x11/PlatformDisplayX11.cpp:
29 (WebCore::PlatformDisplayX11::create): Try to create a native X11 display or return nullptr.
30 (WebCore::PlatformDisplayX11::PlatformDisplayX11): Use NativeDisplayOwned now.
31 (WebCore::PlatformDisplayX11::~PlatformDisplayX11): Ditto.
32 * platform/graphics/x11/PlatformDisplayX11.h:
33