Changeset 209064 in webkit
- Timestamp:
- Nov 28, 2016 11:34:44 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r209062 r209064 1 2016-11-28 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 Michael Catanzaro. 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 1 34 2016-11-28 Matt Baker <mattbaker@apple.com> 2 35 -
trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp
r207658 r209064 89 89 #endif 90 90 91 #if PLATFORM(X11) 92 return std::make_unique<PlatformDisplayX11>(); 91 #if PLATFORM(WAYLAND) 92 if (auto platformDisplay = PlatformDisplayWayland::create()) 93 return platformDisplay; 94 #endif 95 96 #if PLATFORM(X11) 97 if (auto platformDisplay = PlatformDisplayX11::create()) 98 return platformDisplay; 99 #endif 100 101 // If at this point we still don't have a display, just create a fake display with no native. 102 #if PLATFORM(WAYLAND) 103 return std::make_unique<PlatformDisplayWayland>(nullptr); 104 #endif 105 #if PLATFORM(X11) 106 return std::make_unique<PlatformDisplayX11>(nullptr); 93 107 #endif 94 108 … … 119 133 } 120 134 121 PlatformDisplay::PlatformDisplay() 122 #if USE(EGL) 123 : m_eglDisplay(EGL_NO_DISPLAY) 135 PlatformDisplay::PlatformDisplay(NativeDisplayOwned displayOwned) 136 : m_nativeDisplayOwned(displayOwned) 137 #if USE(EGL) 138 , m_eglDisplay(EGL_NO_DISPLAY) 124 139 #endif 125 140 { -
trunk/Source/WebCore/platform/graphics/PlatformDisplay.h
r207658 r209064 71 71 72 72 protected: 73 PlatformDisplay(); 73 enum class NativeDisplayOwned { No, Yes }; 74 explicit PlatformDisplay(NativeDisplayOwned = NativeDisplayOwned::No); 74 75 75 76 static void setSharedDisplayForCompositing(PlatformDisplay&); 77 78 NativeDisplayOwned m_nativeDisplayOwned { NativeDisplayOwned::No }; 76 79 77 80 #if USE(EGL) -
trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp
r207658 r209064 51 51 }; 52 52 53 PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* display) 53 std::unique_ptr<PlatformDisplay> PlatformDisplayWayland::create() 54 { 55 struct wl_display* display = wl_display_connect(getenv("DISPLAY")); 56 if (!display) 57 return nullptr; 58 59 return std::make_unique<PlatformDisplayWayland>(display, NativeDisplayOwned::Yes); 60 } 61 62 PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* display, NativeDisplayOwned displayOwned) 63 : PlatformDisplay(displayOwned) 54 64 { 55 65 initialize(display); … … 58 68 PlatformDisplayWayland::~PlatformDisplayWayland() 59 69 { 70 if (m_nativeDisplayOwned == NativeDisplayOwned::Yes) 71 wl_display_destroy(m_display); 60 72 } 61 73 … … 63 75 { 64 76 m_display = display; 77 if (!m_display) 78 return; 79 65 80 m_registry.reset(wl_display_get_registry(m_display)); 66 81 wl_registry_add_listener(m_registry.get(), &s_registryListener, this); -
trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h
r205116 r209064 37 37 class PlatformDisplayWayland : public PlatformDisplay { 38 38 public: 39 PlatformDisplayWayland(struct wl_display*); 39 static std::unique_ptr<PlatformDisplay> create(); 40 PlatformDisplayWayland(struct wl_display*, NativeDisplayOwned = NativeDisplayOwned::No); 40 41 virtual ~PlatformDisplayWayland(); 41 42 -
trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp
r208985 r209064 43 43 namespace WebCore { 44 44 45 PlatformDisplayX11::PlatformDisplayX11() 46 : m_display(XOpenDisplay(nullptr)) 45 std::unique_ptr<PlatformDisplay> PlatformDisplayX11::create() 47 46 { 48 m_ownedDisplay = m_display != nullptr; 47 Display* display = XOpenDisplay(getenv("DISPLAY")); 48 if (!display) 49 return nullptr; 50 51 return std::make_unique<PlatformDisplayX11>(display, NativeDisplayOwned::Yes); 49 52 } 50 53 51 PlatformDisplayX11::PlatformDisplayX11(Display* display )52 : m_display(display)53 , m_ ownedDisplay(false)54 PlatformDisplayX11::PlatformDisplayX11(Display* display, NativeDisplayOwned displayOwned) 55 : PlatformDisplay(displayOwned) 56 , m_display(display) 54 57 { 55 58 } … … 61 64 m_sharingGLContext = nullptr; 62 65 #endif 63 if (m_ ownedDisplay)66 if (m_nativeDisplayOwned == NativeDisplayOwned::Yes) 64 67 XCloseDisplay(m_display); 65 68 } -
trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h
r208985 r209064 38 38 class PlatformDisplayX11 final : public PlatformDisplay { 39 39 public: 40 PlatformDisplayX11();41 PlatformDisplayX11(Display* );40 static std::unique_ptr<PlatformDisplay> create(); 41 PlatformDisplayX11(Display*, NativeDisplayOwned = NativeDisplayOwned::No); 42 42 virtual ~PlatformDisplayX11(); 43 43 … … 53 53 #endif 54 54 55 Display* m_display; 56 bool m_ownedDisplay; 55 Display* m_display { nullptr }; 57 56 mutable std::optional<bool> m_supportsXComposite; 58 57 mutable std::optional<bool> m_supportsXDamage;
Note: See TracChangeset
for help on using the changeset viewer.