Title: [265738] releases/WebKitGTK/webkit-2.28/Source/WebCore
Revision
265738
Author
[email protected]
Date
2020-08-15 13:26:15 -0700 (Sat, 15 Aug 2020)

Log Message

Merged r264986 - [GTK] Crash in Nicosia::GC3DLayer::makeContextCurrent due to failure in EGL display creation
https://bugs.webkit.org/show_bug.cgi?id=201507

Reviewed by Carlos Garcia Campos.

Ensure that EGL context and display creation failures are always
logged using RELEASE_LOG_INFO(), even for intermediate failures for
which a fallback will be tried next, in order to ease diagnosis of
related issues. Failure to create contexts at the end of the public
methods ::createContext() and ::createSharingContext() is still
logged with WTFLogAlways() to write a notice to standard error, and
let users/developers know that something failed and checking the
complete logs (e.g. with "journalctl" on Linux) may reveal more
information.

This also replaces the chains of "if" statements with a single
"switch" on the PlatformDisplay::Type enum, which makes the code
easier to follow and should be more robust as well.

No new tests needed.

* platform/graphics/egl/GLContextEGL.cpp:
(WebCore::GLContextEGL::getEGLConfig):
(WebCore::GLContextEGL::createWindowContext):
(WebCore::GLContextEGL::createSurfacelessContext):
(WebCore::GLContextEGL::createContext):
(WebCore::GLContextEGL::createSharingContext):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog (265737 => 265738)


--- releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog	2020-08-15 20:26:09 UTC (rev 265737)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog	2020-08-15 20:26:15 UTC (rev 265738)
@@ -1,3 +1,33 @@
+2020-07-28  Adrian Perez de Castro  <[email protected]>
+
+        [GTK] Crash in Nicosia::GC3DLayer::makeContextCurrent due to failure in EGL display creation
+        https://bugs.webkit.org/show_bug.cgi?id=201507
+
+        Reviewed by Carlos Garcia Campos.
+
+        Ensure that EGL context and display creation failures are always
+        logged using RELEASE_LOG_INFO(), even for intermediate failures for
+        which a fallback will be tried next, in order to ease diagnosis of
+        related issues. Failure to create contexts at the end of the public
+        methods ::createContext() and ::createSharingContext() is still
+        logged with WTFLogAlways() to write a notice to standard error, and
+        let users/developers know that something failed and checking the
+        complete logs (e.g. with "journalctl" on Linux) may reveal more
+        information.
+
+        This also replaces the chains of "if" statements with a single
+        "switch" on the PlatformDisplay::Type enum, which makes the code
+        easier to follow and should be more robust as well.
+
+        No new tests needed.
+
+        * platform/graphics/egl/GLContextEGL.cpp:
+        (WebCore::GLContextEGL::getEGLConfig):
+        (WebCore::GLContextEGL::createWindowContext):
+        (WebCore::GLContextEGL::createSurfacelessContext):
+        (WebCore::GLContextEGL::createContext):
+        (WebCore::GLContextEGL::createSharingContext):
+
 2020-04-03  Jack Lee  <[email protected]>
 
         Protect contentFrame in SubframeLoader::loadOrRedirectSubframe with RefPtr.

Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp (265737 => 265738)


--- releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2020-08-15 20:26:09 UTC (rev 265737)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2020-08-15 20:26:15 UTC (rev 265738)
@@ -22,6 +22,7 @@
 #if USE(EGL)
 
 #include "GraphicsContextGLOpenGL.h"
+#include "Logging.h"
 #include "PlatformDisplay.h"
 
 #if USE(LIBEPOXY)
@@ -57,8 +58,10 @@
 namespace WebCore {
 
 #if USE(OPENGL_ES)
+static const char* gEGLAPIName = "OpenGL ES";
 static const EGLenum gEGLAPIVersion = EGL_OPENGL_ES_API;
 #else
+static const char* gEGLAPIName = "OpenGL";
 static const EGLenum gEGLAPIVersion = EGL_OPENGL_API;
 #endif
 
@@ -132,13 +135,17 @@
     }
 
     EGLint count;
-    if (!eglChooseConfig(display, attributeList, nullptr, 0, &count))
+    if (!eglChooseConfig(display, attributeList, nullptr, 0, &count)) {
+        RELEASE_LOG_INFO(Compositing, "Cannot get count of available EGL configurations: %s.", lastErrorString());
         return false;
+    }
 
     EGLint numberConfigsReturned;
     Vector<EGLConfig> configs(count);
-    if (!eglChooseConfig(display, attributeList, reinterpret_cast<EGLConfig*>(configs.data()), count, &numberConfigsReturned) || !numberConfigsReturned)
+    if (!eglChooseConfig(display, attributeList, reinterpret_cast<EGLConfig*>(configs.data()), count, &numberConfigsReturned) || !numberConfigsReturned) {
+        RELEASE_LOG_INFO(Compositing, "Cannot get available EGL configurations: %s.", lastErrorString());
         return false;
+    }
 
     auto index = configs.findMatching([&](EGLConfig value) {
         EGLint redSize, greenSize, blueSize, alphaSize;
@@ -154,6 +161,8 @@
         *config = configs[index];
         return true;
     }
+
+    RELEASE_LOG_INFO(Compositing, "Could not find suitable EGL configuration out of %zu checked.", configs.size());
     return false;
 }
 
@@ -162,37 +171,42 @@
     EGLDisplay display = platformDisplay.eglDisplay();
     EGLConfig config;
     if (!getEGLConfig(display, &config, WindowSurface)) {
-        WTFLogAlways("Cannot obtain EGL window context configuration: %s\n", lastErrorString());
+        RELEASE_LOG_INFO(Compositing, "Cannot obtain EGL window context configuration: %s\n", lastErrorString());
         return nullptr;
     }
 
     EGLContext context = createContextForEGLVersion(platformDisplay, config, sharingContext);
     if (context == EGL_NO_CONTEXT) {
-        WTFLogAlways("Cannot create EGL window context: %s\n", lastErrorString());
+        RELEASE_LOG_INFO(Compositing, "Cannot create EGL window context: %s\n", lastErrorString());
         return nullptr;
     }
 
-    EGLSurface surface = EGL_NO_SURFACE;
-#if PLATFORM(GTK)
+    EGLSurface surface;
+    switch (platformDisplay.type()) {
 #if PLATFORM(X11)
-    if (platformDisplay.type() == PlatformDisplay::Type::X11)
+    case PlatformDisplay::Type::X11:
         surface = createWindowSurfaceX11(display, config, window);
+        break;
 #endif
 #if PLATFORM(WAYLAND)
-    if (platformDisplay.type() == PlatformDisplay::Type::Wayland)
+    case PlatformDisplay::Type::Wayland:
         surface = createWindowSurfaceWayland(display, config, window);
+        break;
 #endif
-#endif
-
 #if USE(WPE_RENDERER)
-    if (platformDisplay.type() == PlatformDisplay::Type::WPE)
+    case PlatformDisplay::Type::WPE:
         surface = createWindowSurfaceWPE(display, config, window);
-#else
-    if (surface == EGL_NO_SURFACE)
+        break;
+#endif // USE(WPE_RENDERER)
+    }
+
+    if (surface == EGL_NO_SURFACE) {
+        RELEASE_LOG_INFO(Compositing, "Cannot create EGL window surface: %s. Retrying with fallback.", lastErrorString());
         surface = eglCreateWindowSurface(display, config, static_cast<EGLNativeWindowType>(window), nullptr);
-#endif
+    }
+
     if (surface == EGL_NO_SURFACE) {
-        WTFLogAlways("Cannot create EGL window surface: %s\n", lastErrorString());
+        RELEASE_LOG_INFO(Compositing, "Cannot create EGL window surface: %s\n", lastErrorString());
         eglDestroyContext(display, context);
         return nullptr;
     }
@@ -205,13 +219,13 @@
     EGLDisplay display = platformDisplay.eglDisplay();
     EGLConfig config;
     if (!getEGLConfig(display, &config, PbufferSurface)) {
-        WTFLogAlways("Cannot obtain EGL Pbuffer configuration: %s\n", lastErrorString());
+        RELEASE_LOG_INFO(Compositing, "Cannot obtain EGL Pbuffer configuration: %s\n", lastErrorString());
         return nullptr;
     }
 
     EGLContext context = createContextForEGLVersion(platformDisplay, config, sharingContext);
     if (context == EGL_NO_CONTEXT) {
-        WTFLogAlways("Cannot create EGL Pbuffer context: %s\n", lastErrorString());
+        RELEASE_LOG_INFO(Compositing, "Cannot create EGL Pbuffer context: %s\n", lastErrorString());
         return nullptr;
     }
 
@@ -218,7 +232,7 @@
     static const int pbufferAttributes[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE };
     EGLSurface surface = eglCreatePbufferSurface(display, config, pbufferAttributes);
     if (surface == EGL_NO_SURFACE) {
-        WTFLogAlways("Cannot create EGL Pbuffer surface: %s\n", lastErrorString());
+        RELEASE_LOG_INFO(Compositing, "Cannot create EGL Pbuffer surface: %s\n", lastErrorString());
         eglDestroyContext(display, context);
         return nullptr;
     }
@@ -230,23 +244,25 @@
 {
     EGLDisplay display = platformDisplay.eglDisplay();
     if (display == EGL_NO_DISPLAY) {
-        WTFLogAlways("Cannot create surfaceless EGL context: invalid display (last error: %s)\n", lastErrorString());
+        RELEASE_LOG_INFO(Compositing, "Cannot create surfaceless EGL context: invalid display (last error: %s)\n", lastErrorString());
         return nullptr;
     }
 
     const char* extensions = eglQueryString(display, EGL_EXTENSIONS);
-    if (!GLContext::isExtensionSupported(extensions, "EGL_KHR_surfaceless_context") && !GLContext::isExtensionSupported(extensions, "EGL_KHR_surfaceless_opengl"))
+    if (!GLContext::isExtensionSupported(extensions, "EGL_KHR_surfaceless_context") && !GLContext::isExtensionSupported(extensions, "EGL_KHR_surfaceless_opengl")) {
+        RELEASE_LOG_INFO(Compositing, "Cannot create surfaceless EGL context: required extensions missing.");
         return nullptr;
+    }
 
     EGLConfig config;
     if (!getEGLConfig(display, &config, Surfaceless)) {
-        WTFLogAlways("Cannot obtain EGL surfaceless configuration: %s\n", lastErrorString());
+        RELEASE_LOG_INFO(Compositing, "Cannot obtain EGL surfaceless configuration: %s\n", lastErrorString());
         return nullptr;
     }
 
     EGLContext context = createContextForEGLVersion(platformDisplay, config, sharingContext);
     if (context == EGL_NO_CONTEXT) {
-        WTFLogAlways("Cannot create EGL surfaceless context: %s\n", lastErrorString());
+        RELEASE_LOG_INFO(Compositing, "Cannot create EGL surfaceless context: %s\n", lastErrorString());
         return nullptr;
     }
 
@@ -261,11 +277,7 @@
     }
 
     if (eglBindAPI(gEGLAPIVersion) == EGL_FALSE) {
-#if USE(OPENGL_ES)
-        WTFLogAlways("Cannot create EGL context: error binding OpenGL ES API (%s)\n", lastErrorString());
-#else
-        WTFLogAlways("Cannot create EGL context: error binding OpenGL API (%s)\n", lastErrorString());
-#endif
+        WTFLogAlways("Cannot create EGL context: error binding %s API (%s)\n", gEGLAPIName, lastErrorString());
         return nullptr;
     }
 
@@ -274,22 +286,33 @@
     if (!context)
         context = createSurfacelessContext(platformDisplay, eglSharingContext);
     if (!context) {
+        switch (platformDisplay.type()) {
 #if PLATFORM(X11)
-        if (platformDisplay.type() == PlatformDisplay::Type::X11)
+        case PlatformDisplay::Type::X11:
             context = createPixmapContext(platformDisplay, eglSharingContext);
+            break;
 #endif
 #if PLATFORM(WAYLAND)
-        if (platformDisplay.type() == PlatformDisplay::Type::Wayland)
+        case PlatformDisplay::Type::Wayland:
             context = createWaylandContext(platformDisplay, eglSharingContext);
+            break;
 #endif
 #if USE(WPE_RENDERER)
-        if (platformDisplay.type() == PlatformDisplay::Type::WPE)
+        case PlatformDisplay::Type::WPE:
             context = createWPEContext(platformDisplay, eglSharingContext);
+            break;
 #endif
+        }
     }
-    if (!context)
+    if (!context) {
+        RELEASE_LOG_INFO(Compositing, "Could not create platform context: %s. Using Pbuffer as fallback.", lastErrorString());
         context = createPbufferContext(platformDisplay, eglSharingContext);
+        if (!context)
+            RELEASE_LOG_INFO(Compositing, "Could not create Pbuffer context: %s.", lastErrorString());
+    }
 
+    if (!context)
+        WTFLogAlways("Could not create EGL context.");
     return context;
 }
 
@@ -301,32 +324,39 @@
     }
 
     if (eglBindAPI(gEGLAPIVersion) == EGL_FALSE) {
-#if USE(OPENGL_ES)
-        WTFLogAlways("Cannot create EGL sharing context: error binding OpenGL ES API (%s)\n", lastErrorString());
-#else
-        WTFLogAlways("Cannot create EGL sharing context: error binding OpenGL API (%s)\n", lastErrorString());
-#endif
+        WTFLogAlways("Cannot create EGL sharing context: error binding %s API (%s)\n", gEGLAPIName, lastErrorString());
         return nullptr;
     }
 
     auto context = createSurfacelessContext(platformDisplay);
     if (!context) {
+        switch (platformDisplay.type()) {
 #if PLATFORM(X11)
-        if (platformDisplay.type() == PlatformDisplay::Type::X11)
+        case PlatformDisplay::Type::X11:
             context = createPixmapContext(platformDisplay);
+            break;
 #endif
 #if PLATFORM(WAYLAND)
-        if (platformDisplay.type() == PlatformDisplay::Type::Wayland)
+        case PlatformDisplay::Type::Wayland:
             context = createWaylandContext(platformDisplay);
+            break;
 #endif
 #if USE(WPE_RENDERER)
-        if (platformDisplay.type() == PlatformDisplay::Type::WPE)
+        case PlatformDisplay::Type::WPE:
             context = createWPEContext(platformDisplay);
+            break;
 #endif
+        }
     }
-    if (!context)
+    if (!context) {
+        RELEASE_LOG_INFO(Compositing, "Could not create platform context: %s. Using Pbuffer as fallback.", lastErrorString());
         context = createPbufferContext(platformDisplay);
+        if (!context)
+            RELEASE_LOG_INFO(Compositing, "Could not create Pbuffer context: %s.", lastErrorString());
+    }
 
+    if (!context)
+        WTFLogAlways("Could not create EGL sharing context.");
     return context;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to