From 0954220cbf07f036fc14235211344af3f760fe97 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Wed, 26 Jun 2024 15:10:18 -0700 Subject: [PATCH] Return a null image from ImageExternalTextureGL::CreateEGLImage if an EGL display is not available (flutter/engine#53594) 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/engine/src/flutter/shell/platform/android/image_external_texture_gl.cc b/engine/src/flutter/shell/platform/android/image_external_texture_gl.cc index 92743654d0..88792d73d8 100644 --- a/engine/src/flutter/shell/platform/android/image_external_texture_gl.cc +++ b/engine/src/flutter/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(