Changeset 224347 in webkit
- Timestamp:
- Nov 2, 2017 11:55:57 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r224345 r224347 1 2017-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 1 31 2017-11-02 Joseph Pecoraro <pecoraro@apple.com> 2 32 -
trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp
r219819 r224347 65 65 #include <EGL/egl.h> 66 66 #endif 67 #include "GLContextEGL.h" 67 68 #include <wtf/HashSet.h> 68 69 #include <wtf/NeverDestroyed.h> … … 198 199 if (m_eglDisplay == EGL_NO_DISPLAY) { 199 200 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()); 201 203 return; 204 } 202 205 } 203 206 204 207 EGLint majorVersion, minorVersion; 205 208 if (eglInitialize(m_eglDisplay, &majorVersion, &minorVersion) == EGL_FALSE) { 206 LOG_ERROR("EGLDisplay Initialization failed.");209 WTFLogAlways("EGLDisplay Initialization failed: %s\n", GLContextEGL::lastErrorString()); 207 210 terminateEGLDisplay(); 208 211 return; -
trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp
r219819 r224347 68 68 #endif 69 69 70 const 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 96 const char* GLContextEGL::lastErrorString() 97 { 98 return errorString(eglGetError()); 99 } 100 70 101 bool GLContextEGL::getEGLConfig(EGLDisplay display, EGLConfig* config, EGLSurfaceType surfaceType) 71 102 { … … 106 137 EGLDisplay display = platformDisplay.eglDisplay(); 107 138 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 } 110 143 111 144 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 } 114 149 115 150 EGLSurface surface = EGL_NO_SURFACE; … … 130 165 #endif 131 166 if (surface == EGL_NO_SURFACE) { 167 WTFLogAlways("Cannot create EGL window surface: %s\n", lastErrorString()); 132 168 eglDestroyContext(display, context); 133 169 return nullptr; … … 141 177 EGLDisplay display = platformDisplay.eglDisplay(); 142 178 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 } 145 183 146 184 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 } 149 189 150 190 static const int pbufferAttributes[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE }; 151 191 EGLSurface surface = eglCreatePbufferSurface(display, config, pbufferAttributes); 152 192 if (surface == EGL_NO_SURFACE) { 193 WTFLogAlways("Cannot create EGL Pbuffer surface: %s\n", lastErrorString()); 153 194 eglDestroyContext(display, context); 154 195 return nullptr; … … 161 202 { 162 203 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 } 165 208 166 209 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 } 169 214 170 215 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 } 173 220 174 221 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 } 177 226 178 227 return std::unique_ptr<GLContextEGL>(new GLContextEGL(platformDisplay, context, EGL_NO_SURFACE, Surfaceless)); … … 181 230 std::unique_ptr<GLContextEGL> GLContextEGL::createContext(GLNativeWindowType window, PlatformDisplay& platformDisplay) 182 231 { 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 } 188 245 189 246 EGLContext eglSharingContext = platformDisplay.sharingGLContext() ? static_cast<GLContextEGL*>(platformDisplay.sharingGLContext())->m_context : EGL_NO_CONTEXT; … … 213 270 std::unique_ptr<GLContextEGL> GLContextEGL::createSharingContext(PlatformDisplay& platformDisplay) 214 271 { 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 } 220 285 221 286 auto context = createSurfacelessContext(platformDisplay); … … 248 313 ASSERT(type != PixmapSurface); 249 314 ASSERT(type == Surfaceless || surface != EGL_NO_SURFACE); 315 RELEASE_ASSERT(m_display.eglDisplay() != EGL_NO_DISPLAY); 316 RELEASE_ASSERT(context != EGL_NO_CONTEXT); 250 317 } 251 318 -
trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h
r217208 r224347 49 49 static std::unique_ptr<GLContextEGL> createContext(GLNativeWindowType, PlatformDisplay&); 50 50 static std::unique_ptr<GLContextEGL> createSharingContext(PlatformDisplay&); 51 52 static const char* errorString(int statusCode); 53 static const char* lastErrorString(); 51 54 52 55 virtual ~GLContextEGL(); -
trunk/Source/WebCore/platform/graphics/egl/GLContextEGLWPE.cpp
r219819 r224347 53 53 EGLDisplay display = platformDisplay.eglDisplay(); 54 54 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()); 56 57 return nullptr; 58 } 57 59 58 60 static const EGLint contextAttributes[] = { … … 64 66 65 67 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()); 67 70 return nullptr; 71 } 68 72 69 73 auto* target = wpe_renderer_backend_egl_offscreen_target_create(); … … 71 75 EGLNativeWindowType window = wpe_renderer_backend_egl_offscreen_target_get_native_window(target); 72 76 if (!window) { 77 WTFLogAlways("Cannot create EGL WPE context: %s\n", lastErrorString()); 73 78 wpe_renderer_backend_egl_offscreen_target_destroy(target); 74 79 return nullptr; … … 77 82 EGLSurface surface = eglCreateWindowSurface(display, config, static_cast<EGLNativeWindowType>(window), nullptr); 78 83 if (surface == EGL_NO_SURFACE) { 84 WTFLogAlways("Cannot create EGL WPE window surface: %s\n", lastErrorString()); 79 85 eglDestroyContext(display, context); 80 86 wpe_renderer_backend_egl_offscreen_target_destroy(target); -
trunk/Source/WebCore/platform/graphics/wpe/PlatformDisplayWPE.cpp
r219819 r224347 55 55 m_eglDisplay = eglGetDisplay(wpe_renderer_backend_egl_get_native_display(m_backend)); 56 56 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()); 58 58 return; 59 59 }
Note: See TracChangeset
for help on using the changeset viewer.