diff --git a/lib/ui/painting/image_decoder_impeller.cc b/lib/ui/painting/image_decoder_impeller.cc index 099d1a4fef396..7532399699d46 100644 --- a/lib/ui/painting/image_decoder_impeller.cc +++ b/lib/ui/painting/image_decoder_impeller.cc @@ -490,17 +490,28 @@ void ImageDecoderImpeller::Decode(fml::RefPtr descriptor, sk_sp image; std::string decode_error; - if (context->GetCapabilities()->SupportsBufferToTextureBlits()) { - std::tie(image, decode_error) = UploadTextureToPrivate( - context, bitmap_result.device_buffer, bitmap_result.image_info, - bitmap_result.sk_bitmap, gpu_disabled_switch); - result(image, decode_error); + auto upload_texture_and_invoke_result = [result, context, bitmap_result, + gpu_disabled_switch]() { + sk_sp image; + std::string decode_error; + if (context->GetCapabilities()->SupportsBufferToTextureBlits()) { + std::tie(image, decode_error) = UploadTextureToPrivate( + context, bitmap_result.device_buffer, bitmap_result.image_info, + bitmap_result.sk_bitmap, gpu_disabled_switch); + result(image, decode_error); + } else { + std::tie(image, decode_error) = UploadTextureToStorage( + context, bitmap_result.sk_bitmap, gpu_disabled_switch, + impeller::StorageMode::kDevicePrivate, + /*create_mips=*/true); + result(image, decode_error); + } + }; + if (context->GetBackendType() == + impeller::Context::BackendType::kOpenGLES) { + io_runner->PostTask(upload_texture_and_invoke_result); } else { - std::tie(image, decode_error) = UploadTextureToStorage( - context, bitmap_result.sk_bitmap, gpu_disabled_switch, - impeller::StorageMode::kDevicePrivate, - /*create_mips=*/true); - result(image, decode_error); + upload_texture_and_invoke_result(); } }); }