From 8e1702b29c8ab76d85eaa5ca784c89720ef2e0f0 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 11 Nov 2024 19:17:13 -0800 Subject: [PATCH] [Impeller] prevent no-op backend from throwing exceptions during image decoding. --- lib/ui/painting/image_decoder_impeller.cc | 7 +++++++ lib/ui/painting/multi_frame_codec.cc | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/ui/painting/image_decoder_impeller.cc b/lib/ui/painting/image_decoder_impeller.cc index 6a1118954a9be..a73310c492b2e 100644 --- a/lib/ui/painting/image_decoder_impeller.cc +++ b/lib/ui/painting/image_decoder_impeller.cc @@ -519,6 +519,13 @@ void ImageDecoderImpeller::Decode(fml::RefPtr descriptor, result, supports_wide_gamut = supports_wide_gamut_, // gpu_disabled_switch = gpu_disabled_switch_]() { +#if FML_OS_IOS_SIMULATOR + // No-op backend. + if (!context) { + return; + } +#endif // FML_OS_IOS_SIMULATOR + if (!context) { result(nullptr, "No Impeller context is available"); return; diff --git a/lib/ui/painting/multi_frame_codec.cc b/lib/ui/painting/multi_frame_codec.cc index 1521c535fd97c..f05ff111236ce 100644 --- a/lib/ui/painting/multi_frame_codec.cc +++ b/lib/ui/painting/multi_frame_codec.cc @@ -190,6 +190,17 @@ void MultiFrameCodec::State::GetNextFrameAndInvokeCallback( const std::shared_ptr& gpu_disable_sync_switch, size_t trace_id, const std::shared_ptr& impeller_context) { +#if FML_OS_IOS_SIMULATOR + // Noop backend. + if (!resourceContext && !impeller_context) { + ui_task_runner->PostTask( + fml::MakeCopyable([callback = std::move(callback)]() { + // must be destroyed on UI thread. + })); + return; + } +#endif // FML_OS_IOS_SIMULATOR + fml::RefPtr image = nullptr; int duration = 0; sk_sp dlImage;