summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/PlatformDisplay.cpp
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-09-28 16:39:37 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:31:01 +0000
commit9daf1655d7e4eaaa6ed5f44055a4b4fd399fd25c (patch)
tree322337ad0acbc75732f916376ec6d36e7ec0e5bc /Source/WebCore/platform/graphics/PlatformDisplay.cpp
parent6882a04fb36642862b11efe514251d32070c3d65 (diff)
Imported WebKit commit eb954cdcf58f9b915b2fcb6f8e4cb3a60650a4f3
Change-Id: I8dda875c38075d43b76fe3a21acb0ffa102bb82d Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebCore/platform/graphics/PlatformDisplay.cpp')
-rw-r--r--Source/WebCore/platform/graphics/PlatformDisplay.cpp18
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);