From 9769b476b0853270492fb4f4758baa338675ebb2 Mon Sep 17 00:00:00 2001 From: Andrew Osmond Date: Thu, 27 Jan 2022 17:07:19 +0000 Subject: [PATCH] Bug 1751816 - Improve error handling in GLContextEGL::CreateCompatibleSurface. r=jgilbert Rather than just crashing, if we return a nullptr in CreateCompatibleSurface, then we will just cause a context loss for WebGL instances. This would be better for beta/release than just crashing the content process on the user. So that we can get a sense of what errors are causing this, we should record it to the critical log. This will still crash on nightly as well so we should get the reports. Differential Revision: https://phabricator.services.mozilla.com/D136825 --- gfx/gl/GLContextProviderEGL.cpp | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index cd91862657e0..5243dab4b7f7 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -999,29 +999,14 @@ already_AddRefed GLContextProviderEGL::CreateForCompositorWidget( EGLSurface GLContextEGL::CreateCompatibleSurface(void* aWindow) const { MOZ_ASSERT(aWindow); - if (mConfig == EGL_NO_CONFIG) { - MOZ_CRASH("GFX: Failed with invalid EGLConfig 2!"); - } + MOZ_RELEASE_ASSERT(mConfig != EGL_NO_CONFIG); - const auto fnCreate = [&](const bool useGles) -> EGLSurface { - // NOTE: aWindow is an ANativeWindow - auto config = mConfig; - if (!config && !CreateConfigScreen(*mEgl, &config, - /* aEnableDepthBuffer */ false, - /* useGles */ useGles)) { - return nullptr; - } - - return mEgl->fCreateWindowSurface( - config, reinterpret_cast(aWindow), 0); - }; - - auto surface = fnCreate(false); + // NOTE: aWindow is an ANativeWindow + EGLSurface surface = mEgl->fCreateWindowSurface( + mConfig, reinterpret_cast(aWindow), nullptr); if (!surface) { - surface = fnCreate(true); - } - if (!surface) { - MOZ_CRASH("GFX: Failed to create EGLSurface 2!"); + gfxCriticalError() << "CreateCompatibleSurface failed: " + << hexa(GetError()); } return surface; }