Changeset 224347 in webkit


Ignore:
Timestamp:
Nov 2, 2017 11:55:57 AM (6 years ago)
Author:
Adrian Perez de Castro
Message:

[WPE] Add some error reporting during EGL display/context creation
https://bugs.webkit.org/show_bug.cgi?id=178937

Reviewed by Carlos Alberto Lopez Perez.

Unconditionally log errors using WTFLogAlways during EGL context creation. This
provides a small degree of help for troubleshooting, and while eglGetError() only
returns numeric error codes, it's better than nothing.

No new tests needed.

  • platform/graphics/PlatformDisplay.cpp:

(WebCore::PlatformDisplay::initializeEGLDisplay):

  • platform/graphics/egl/GLContextEGL.cpp:

(WebCore::GLContextEGL::errorString):
(WebCore::GLContextEGL::lastErrorString):
(WebCore::GLContextEGL::createWindowContext):
(WebCore::GLContextEGL::createPbufferContext):
(WebCore::GLContextEGL::createSurfacelessContext):
(WebCore::GLContextEGL::createContext):
(WebCore::GLContextEGL::createSharingContext):
(WebCore::GLContextEGL::GLContextEGL):

  • platform/graphics/egl/GLContextEGL.h:
  • platform/graphics/egl/GLContextEGLWPE.cpp:

(WebCore::GLContextEGL::createWPEContext):

  • platform/graphics/wpe/PlatformDisplayWPE.cpp:

(WebCore::PlatformDisplayWPE::initialize):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r224345 r224347  
     12017-11-02  Adrian Perez de Castro  <aperez@igalia.com>
     2
     3        [WPE] Add some error reporting during EGL display/context creation
     4        https://bugs.webkit.org/show_bug.cgi?id=178937
     5
     6        Reviewed by Carlos Alberto Lopez Perez.
     7
     8        Unconditionally log errors using WTFLogAlways during EGL context creation. This
     9        provides a small degree of help for troubleshooting, and while eglGetError() only
     10        returns numeric error codes, it's better than nothing.
     11
     12        No new tests needed.
     13
     14        * platform/graphics/PlatformDisplay.cpp:
     15        (WebCore::PlatformDisplay::initializeEGLDisplay):
     16        * platform/graphics/egl/GLContextEGL.cpp:
     17        (WebCore::GLContextEGL::errorString):
     18        (WebCore::GLContextEGL::lastErrorString):
     19        (WebCore::GLContextEGL::createWindowContext):
     20        (WebCore::GLContextEGL::createPbufferContext):
     21        (WebCore::GLContextEGL::createSurfacelessContext):
     22        (WebCore::GLContextEGL::createContext):
     23        (WebCore::GLContextEGL::createSharingContext):
     24        (WebCore::GLContextEGL::GLContextEGL):
     25        * platform/graphics/egl/GLContextEGL.h:
     26        * platform/graphics/egl/GLContextEGLWPE.cpp:
     27        (WebCore::GLContextEGL::createWPEContext):
     28        * platform/graphics/wpe/PlatformDisplayWPE.cpp:
     29        (WebCore::PlatformDisplayWPE::initialize):
     30
    1312017-11-02  Joseph Pecoraro  <pecoraro@apple.com>
    232
  • trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp

    r219819 r224347  
    6565#include <EGL/egl.h>
    6666#endif
     67#include "GLContextEGL.h"
    6768#include <wtf/HashSet.h>
    6869#include <wtf/NeverDestroyed.h>
     
    198199    if (m_eglDisplay == EGL_NO_DISPLAY) {
    199200        m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    200         if (m_eglDisplay == EGL_NO_DISPLAY)
     201        if (m_eglDisplay == EGL_NO_DISPLAY) {
     202            WTFLogAlways("Cannot get default EGL display: %s\n", GLContextEGL::lastErrorString());
    201203            return;
     204        }
    202205    }
    203206
    204207    EGLint majorVersion, minorVersion;
    205208    if (eglInitialize(m_eglDisplay, &majorVersion, &minorVersion) == EGL_FALSE) {
    206         LOG_ERROR("EGLDisplay Initialization failed.");
     209        WTFLogAlways("EGLDisplay Initialization failed: %s\n", GLContextEGL::lastErrorString());
    207210        terminateEGLDisplay();
    208211        return;
  • trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp

    r219819 r224347  
    6868#endif
    6969
     70const char* GLContextEGL::errorString(int statusCode)
     71{
     72    static_assert(sizeof(int) >= sizeof(EGLint), "EGLint must not be wider than int");
     73    switch (statusCode) {
     74#define CASE_RETURN_STRING(name) case name: return #name
     75        // https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglGetError.xhtml
     76        CASE_RETURN_STRING(EGL_SUCCESS);
     77        CASE_RETURN_STRING(EGL_NOT_INITIALIZED);
     78        CASE_RETURN_STRING(EGL_BAD_ACCESS);
     79        CASE_RETURN_STRING(EGL_BAD_ALLOC);
     80        CASE_RETURN_STRING(EGL_BAD_ATTRIBUTE);
     81        CASE_RETURN_STRING(EGL_BAD_CONTEXT);
     82        CASE_RETURN_STRING(EGL_BAD_CONFIG);
     83        CASE_RETURN_STRING(EGL_BAD_CURRENT_SURFACE);
     84        CASE_RETURN_STRING(EGL_BAD_DISPLAY);
     85        CASE_RETURN_STRING(EGL_BAD_SURFACE);
     86        CASE_RETURN_STRING(EGL_BAD_MATCH);
     87        CASE_RETURN_STRING(EGL_BAD_PARAMETER);
     88        CASE_RETURN_STRING(EGL_BAD_NATIVE_PIXMAP);
     89        CASE_RETURN_STRING(EGL_BAD_NATIVE_WINDOW);
     90        CASE_RETURN_STRING(EGL_CONTEXT_LOST);
     91#undef CASE_RETURN_STRING
     92    default: return "Unknown EGL error";
     93    }
     94}
     95
     96const char* GLContextEGL::lastErrorString()
     97{
     98    return errorString(eglGetError());
     99}
     100
    70101bool GLContextEGL::getEGLConfig(EGLDisplay display, EGLConfig* config, EGLSurfaceType surfaceType)
    71102{
     
    106137    EGLDisplay display = platformDisplay.eglDisplay();
    107138    EGLConfig config;
    108     if (!getEGLConfig(display, &config, WindowSurface))
    109         return nullptr;
     139    if (!getEGLConfig(display, &config, WindowSurface)) {
     140        WTFLogAlways("Cannot obtain EGL window context configuration: %s\n", lastErrorString());
     141        return nullptr;
     142    }
    110143
    111144    EGLContext context = eglCreateContext(display, config, sharingContext, gContextAttributes);
    112     if (context == EGL_NO_CONTEXT)
    113         return nullptr;
     145    if (context == EGL_NO_CONTEXT) {
     146        WTFLogAlways("Cannot create EGL window context: %s\n", lastErrorString());
     147        return nullptr;
     148    }
    114149
    115150    EGLSurface surface = EGL_NO_SURFACE;
     
    130165#endif
    131166    if (surface == EGL_NO_SURFACE) {
     167        WTFLogAlways("Cannot create EGL window surface: %s\n", lastErrorString());
    132168        eglDestroyContext(display, context);
    133169        return nullptr;
     
    141177    EGLDisplay display = platformDisplay.eglDisplay();
    142178    EGLConfig config;
    143     if (!getEGLConfig(display, &config, PbufferSurface))
    144         return nullptr;
     179    if (!getEGLConfig(display, &config, PbufferSurface)) {
     180        WTFLogAlways("Cannot obtain EGL Pbuffer configuration: %s\n", lastErrorString());
     181        return nullptr;
     182    }
    145183
    146184    EGLContext context = eglCreateContext(display, config, sharingContext, gContextAttributes);
    147     if (context == EGL_NO_CONTEXT)
    148         return nullptr;
     185    if (context == EGL_NO_CONTEXT) {
     186        WTFLogAlways("Cannot create EGL Pbuffer context: %s\n", lastErrorString());
     187        return nullptr;
     188    }
    149189
    150190    static const int pbufferAttributes[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE };
    151191    EGLSurface surface = eglCreatePbufferSurface(display, config, pbufferAttributes);
    152192    if (surface == EGL_NO_SURFACE) {
     193        WTFLogAlways("Cannot create EGL Pbuffer surface: %s\n", lastErrorString());
    153194        eglDestroyContext(display, context);
    154195        return nullptr;
     
    161202{
    162203    EGLDisplay display = platformDisplay.eglDisplay();
    163     if (display == EGL_NO_DISPLAY)
    164         return nullptr;
     204    if (display == EGL_NO_DISPLAY) {
     205        WTFLogAlways("Cannot create surfaceless EGL context: invalid display (last error: %s)\n", lastErrorString());
     206        return nullptr;
     207    }
    165208
    166209    const char* extensions = eglQueryString(display, EGL_EXTENSIONS);
    167     if (!GLContext::isExtensionSupported(extensions, "EGL_KHR_surfaceless_context") && !GLContext::isExtensionSupported(extensions, "EGL_KHR_surfaceless_opengl"))
    168         return nullptr;
     210    if (!GLContext::isExtensionSupported(extensions, "EGL_KHR_surfaceless_context") && !GLContext::isExtensionSupported(extensions, "EGL_KHR_surfaceless_opengl")) {
     211        WTFLogAlways("Cannot create EGL surfaceless context: missing EGL_KHR_surfaceless_{context,opengl} extension.\n");
     212        return nullptr;
     213    }
    169214
    170215    EGLConfig config;
    171     if (!getEGLConfig(display, &config, Surfaceless))
    172         return nullptr;
     216    if (!getEGLConfig(display, &config, Surfaceless)) {
     217        WTFLogAlways("Cannot obtain EGL surfaceless configuration: %s\n", lastErrorString());
     218        return nullptr;
     219    }
    173220
    174221    EGLContext context = eglCreateContext(display, config, sharingContext, gContextAttributes);
    175     if (context == EGL_NO_CONTEXT)
    176         return nullptr;
     222    if (context == EGL_NO_CONTEXT) {
     223        WTFLogAlways("Cannot create EGL surfaceless context: %s\n", lastErrorString());
     224        return nullptr;
     225    }
    177226
    178227    return std::unique_ptr<GLContextEGL>(new GLContextEGL(platformDisplay, context, EGL_NO_SURFACE, Surfaceless));
     
    181230std::unique_ptr<GLContextEGL> GLContextEGL::createContext(GLNativeWindowType window, PlatformDisplay& platformDisplay)
    182231{
    183     if (platformDisplay.eglDisplay() == EGL_NO_DISPLAY)
    184         return nullptr;
    185 
    186     if (eglBindAPI(gEGLAPIVersion) == EGL_FALSE)
    187         return nullptr;
     232    if (platformDisplay.eglDisplay() == EGL_NO_DISPLAY) {
     233        WTFLogAlways("Cannot create EGL context: invalid display (last error: %s)\n", lastErrorString());
     234        return nullptr;
     235    }
     236
     237    if (eglBindAPI(gEGLAPIVersion) == EGL_FALSE) {
     238#if USE(OPENGL_ES_2)
     239        WTFLogAlways("Cannot create EGL context: error binding OpenGL ES API (%s)\n", lastErrorString());
     240#else
     241        WTFLogAlways("Cannot create EGL context: error binding OpenGL API (%s)\n", lastErrorString());
     242#endif
     243        return nullptr;
     244    }
    188245
    189246    EGLContext eglSharingContext = platformDisplay.sharingGLContext() ? static_cast<GLContextEGL*>(platformDisplay.sharingGLContext())->m_context : EGL_NO_CONTEXT;
     
    213270std::unique_ptr<GLContextEGL> GLContextEGL::createSharingContext(PlatformDisplay& platformDisplay)
    214271{
    215     if (platformDisplay.eglDisplay() == EGL_NO_DISPLAY)
    216         return nullptr;
    217 
    218     if (eglBindAPI(gEGLAPIVersion) == EGL_FALSE)
    219         return nullptr;
     272    if (platformDisplay.eglDisplay() == EGL_NO_DISPLAY) {
     273        WTFLogAlways("Cannot create EGL sharing context: invalid display (last error: %s)", lastErrorString());
     274        return nullptr;
     275    }
     276
     277    if (eglBindAPI(gEGLAPIVersion) == EGL_FALSE) {
     278#if USE(OPENGL_ES_2)
     279        WTFLogAlways("Cannot create EGL sharing context: error binding OpenGL ES API (%s)\n", lastErrorString());
     280#else
     281        WTFLogAlways("Cannot create EGL sharing context: error binding OpenGL API (%s)\n", lastErrorString());
     282#endif
     283        return nullptr;
     284    }
    220285
    221286    auto context = createSurfacelessContext(platformDisplay);
     
    248313    ASSERT(type != PixmapSurface);
    249314    ASSERT(type == Surfaceless || surface != EGL_NO_SURFACE);
     315    RELEASE_ASSERT(m_display.eglDisplay() != EGL_NO_DISPLAY);
     316    RELEASE_ASSERT(context != EGL_NO_CONTEXT);
    250317}
    251318
  • trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h

    r217208 r224347  
    4949    static std::unique_ptr<GLContextEGL> createContext(GLNativeWindowType, PlatformDisplay&);
    5050    static std::unique_ptr<GLContextEGL> createSharingContext(PlatformDisplay&);
     51
     52    static const char* errorString(int statusCode);
     53    static const char* lastErrorString();
    5154
    5255    virtual ~GLContextEGL();
  • trunk/Source/WebCore/platform/graphics/egl/GLContextEGLWPE.cpp

    r219819 r224347  
    5353    EGLDisplay display = platformDisplay.eglDisplay();
    5454    EGLConfig config;
    55     if (!getEGLConfig(display, &config, WindowSurface))
     55    if (!getEGLConfig(display, &config, WindowSurface)) {
     56        WTFLogAlways("Cannot obtain EGL WPE context configuration: %s\n", lastErrorString());
    5657        return nullptr;
     58    }
    5759
    5860    static const EGLint contextAttributes[] = {
     
    6466
    6567    EGLContext context = eglCreateContext(display, config, sharingContext, contextAttributes);
    66     if (context == EGL_NO_CONTEXT)
     68    if (context == EGL_NO_CONTEXT) {
     69        WTFLogAlways("Cannot create EGL WPE context: %s\n", lastErrorString());
    6770        return nullptr;
     71    }
    6872
    6973    auto* target = wpe_renderer_backend_egl_offscreen_target_create();
     
    7175    EGLNativeWindowType window = wpe_renderer_backend_egl_offscreen_target_get_native_window(target);
    7276    if (!window) {
     77        WTFLogAlways("Cannot create EGL WPE context: %s\n", lastErrorString());
    7378        wpe_renderer_backend_egl_offscreen_target_destroy(target);
    7479        return nullptr;
     
    7782    EGLSurface surface = eglCreateWindowSurface(display, config, static_cast<EGLNativeWindowType>(window), nullptr);
    7883    if (surface == EGL_NO_SURFACE) {
     84        WTFLogAlways("Cannot create EGL WPE window surface: %s\n", lastErrorString());
    7985        eglDestroyContext(display, context);
    8086        wpe_renderer_backend_egl_offscreen_target_destroy(target);
  • trunk/Source/WebCore/platform/graphics/wpe/PlatformDisplayWPE.cpp

    r219819 r224347  
    5555    m_eglDisplay = eglGetDisplay(wpe_renderer_backend_egl_get_native_display(m_backend));
    5656    if (m_eglDisplay == EGL_NO_DISPLAY) {
    57         WTFLogAlways("PlatformDisplayWPE: could not create the EGL display.");
     57        WTFLogAlways("PlatformDisplayWPE: could not create the EGL display: %s.", GLContextEGL::lastErrorString());
    5858        return;
    5959    }
Note: See TracChangeset for help on using the changeset viewer.