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
This commit is contained in:
Andrew Osmond 2022-01-27 17:07:19 +00:00
Родитель f347afc373
Коммит 9769b476b0
1 изменённых файлов: 6 добавлений и 21 удалений

Просмотреть файл

@ -999,29 +999,14 @@ already_AddRefed<GLContext> 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<EGLNativeWindowType>(aWindow), 0);
};
auto surface = fnCreate(false);
// NOTE: aWindow is an ANativeWindow
EGLSurface surface = mEgl->fCreateWindowSurface(
mConfig, reinterpret_cast<EGLNativeWindowType>(aWindow), nullptr);
if (!surface) {
surface = fnCreate(true);
}
if (!surface) {
MOZ_CRASH("GFX: Failed to create EGLSurface 2!");
gfxCriticalError() << "CreateCompatibleSurface failed: "
<< hexa(GetError());
}
return surface;
}