From 4d8773cb650dc6471d4216c2e6592f2e4ca61892 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Mon, 3 Apr 2023 11:42:59 -0700 Subject: [PATCH] [Impeller] Don't crash if the context is unavailable. Fixes https://github.com/flutter/flutter/issues/123027. Turns out, this isn't an issue with back-grounding. This can only happen if the IO manager is torn down before worker pool has had a chance to process the decompression job, or if the UI manager was never setup. It is hard to imaging how this could happen in a real application. If it does though, we should not crash. This patch makes the change to return an error instead. The linked issue was a test environment and the failure was addressed in https://github.com/flutter/engine/pull/40535. --- lib/ui/painting/image_decoder_impeller.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ui/painting/image_decoder_impeller.cc b/lib/ui/painting/image_decoder_impeller.cc index 01ee5ce62616a..4d70397958b8f 100644 --- a/lib/ui/painting/image_decoder_impeller.cc +++ b/lib/ui/painting/image_decoder_impeller.cc @@ -406,7 +406,10 @@ void ImageDecoderImpeller::Decode(fml::RefPtr descriptor, result, supports_wide_gamut = supports_wide_gamut_ // ]() { - FML_CHECK(context) << "No valid impeller context"; + if (!context) { + result(nullptr); + return; + } auto max_size_supported = context->GetResourceAllocator()->GetMaxTextureSizeSupported();