diff options
Diffstat (limited to 'Source/WebCore/platform/graphics/PlatformDisplay.cpp')
-rw-r--r-- | Source/WebCore/platform/graphics/PlatformDisplay.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/Source/WebCore/platform/graphics/PlatformDisplay.cpp b/Source/WebCore/platform/graphics/PlatformDisplay.cpp index 19a6b99a8..bdae5f45f 100644 --- a/Source/WebCore/platform/graphics/PlatformDisplay.cpp +++ b/Source/WebCore/platform/graphics/PlatformDisplay.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "PlatformDisplay.h" +#include <cstdlib> #include <mutex> #include <wtf/NeverDestroyed.h> @@ -112,10 +113,8 @@ PlatformDisplay::PlatformDisplay() PlatformDisplay::~PlatformDisplay() { - // WinCairo crashes when terminating EGL on exit. - // https://bugs.webkit.org/show_bug.cgi?id=145832 -#if USE(EGL) && !PLATFORM(WIN) - terminateEGLDisplay(); +#if USE(EGL) + ASSERT(m_eglDisplay == EGL_NO_DISPLAY); #endif } @@ -159,10 +158,21 @@ void PlatformDisplay::initializeEGLDisplay() terminateEGLDisplay(); return; } + + // EGL registers atexit handlers to cleanup its global display list. + // Since the global PlatformDisplay instance is created before, + // when the PlatformDisplay destructor is called, EGL has already removed the + // display from the list, causing eglTerminate() to crash. So, here we register + // our own atexit handler, after EGL has been initialized and after the global + // instance has been created to ensure we call eglTerminate() before the other + // EGL atexit handlers and the PlatformDisplay destructor. + // See https://bugs.webkit.org/show_bug.cgi?id=157973. + std::atexit([] { PlatformDisplay::sharedDisplay().terminateEGLDisplay(); }); } void PlatformDisplay::terminateEGLDisplay() { + ASSERT(m_eglDisplayInitialized); if (m_eglDisplay == EGL_NO_DISPLAY) return; eglTerminate(m_eglDisplay); |