From 2c4bd021201aeed5b83199c5de518370a328c19a Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Wed, 26 Jun 2024 12:41:18 -0700 Subject: [PATCH] Return a null image from ImageExternalTextureGL::CreateEGLImage if an EGL display is not available Previously CreateEGLImage had been failing an assertion if an EGL display is not active on the calling thread. CreateEGLImage should not assert here because it could be called from a deferred task that runs after the raster thread has lost its EGL state. See https://github.com/flutter/flutter/issues/149396 --- shell/platform/android/image_external_texture_gl.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shell/platform/android/image_external_texture_gl.cc b/shell/platform/android/image_external_texture_gl.cc index 92743654d0289..88792d73d812e 100644 --- a/shell/platform/android/image_external_texture_gl.cc +++ b/shell/platform/android/image_external_texture_gl.cc @@ -87,7 +87,11 @@ impeller::UniqueEGLImageKHR ImageExternalTextureGL::CreateEGLImage( } EGLDisplay display = eglGetCurrentDisplay(); - FML_CHECK(display != EGL_NO_DISPLAY); + if (display == EGL_NO_DISPLAY) { + // This could happen when running in a deferred task that executes after + // the thread has lost its EGL state. + return impeller::UniqueEGLImageKHR(); + } EGLClientBuffer client_buffer = impeller::android::GetProcTable().eglGetNativeClientBufferANDROID(