Bug 1868825 - Leak EGLDisplays on Samsung S22 devices. r=gfx-reviewers,nical,ahale

We are seeing crashes on the european Samsung S22 family of devices in
eglTerminate after updating to Android 14. To work around this we
deliberately leak the EGLDisplay on affected devices. In practice we
only ever use the default EGLDisplay on Android, and calling
eglInitialize multiple times is allowed, so this is fine.

Note this only occurs when running webgl in the content process, which
will occur naturally following enough GPU process crashes that we
disable the GPU process. When webgl is running in the GPU process
webrender keeps the EGLDisplay alive, meaning we never terminate it.

Differential Revision: https://phabricator.services.mozilla.com/D196146
This commit is contained in:
Jamie Nicol 2023-12-13 11:29:18 +00:00
Родитель da8fe65981
Коммит 3104637fd7
1 изменённых файлов: 24 добавлений и 1 удалений

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

@ -11,6 +11,7 @@
#include "base/platform_thread.h" // for PlatformThreadId
#include "gfxEnv.h"
#include "GLConsts.h"
#include "GLTypes.h"
#include "mozilla/EnumTypeTraits.h"
#include "mozilla/gfx/Logging.h"
@ -28,6 +29,7 @@
#ifdef MOZ_WIDGET_ANDROID
# include "mozilla/ProfilerLabels.h"
# include "AndroidBuild.h"
#endif
#if defined(MOZ_X11)
@ -690,6 +692,21 @@ class GLLibraryEGL final {
} mSymbols = {};
};
static bool ShouldLeakEglDisplay() {
// We are seeing crashes in eglTerminate on the Samsung S22 family of devices
// running Android 14, so we leak the EGLDisplay rather than call
// eglTerminate.
#ifdef MOZ_WIDGET_ANDROID
if (jni::GetAPIVersion() >= 34) {
const auto board = java::sdk::Build::BOARD()->ToString();
if (board.EqualsASCII("s5e9925")) {
return true;
}
}
#endif
return false;
}
class EglDisplay final {
public:
const RefPtr<GLLibraryEGL> mLib;
@ -739,7 +756,13 @@ class EglDisplay final {
// -
EGLBoolean fTerminate() { return mLib->fTerminate(mDisplay); }
EGLBoolean fTerminate() {
static const bool shouldLeak = ShouldLeakEglDisplay();
if (shouldLeak) {
return LOCAL_EGL_TRUE;
}
return mLib->fTerminate(mDisplay);
}
EGLBoolean fMakeCurrent(EGLSurface draw, EGLSurface read,
EGLContext ctx) const {