From 5d5a04b2b3e01b517d5f177ee7ddd56f842fcb1d Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Wed, 16 Nov 2022 14:08:04 -0800 Subject: [PATCH] Fix potential null-point references (flutter/engine#37678) --- .../impeller/renderer/backend/vulkan/command_buffer_vk.cc | 3 ++- .../src/flutter/lib/ui/painting/image_decoder_impeller.cc | 6 +++--- .../platform/android/android_surface_vulkan_impeller.cc | 5 +++++ .../platform/android/android_surface_vulkan_impeller.h | 3 +++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/impeller/renderer/backend/vulkan/command_buffer_vk.cc b/engine/src/flutter/impeller/renderer/backend/vulkan/command_buffer_vk.cc index af8ab6d6b9..6db5c36c2c 100644 --- a/engine/src/flutter/impeller/renderer/backend/vulkan/command_buffer_vk.cc +++ b/engine/src/flutter/impeller/renderer/backend/vulkan/command_buffer_vk.cc @@ -129,7 +129,8 @@ std::shared_ptr CommandBufferVK::OnCreateRenderPass( } std::shared_ptr CommandBufferVK::OnCreateBlitPass() const { - FML_UNREACHABLE(); + // TODO(kaushikiska): https://github.com/flutter/flutter/issues/112649 + return nullptr; } std::shared_ptr CommandBufferVK::OnCreateComputePass() const { diff --git a/engine/src/flutter/lib/ui/painting/image_decoder_impeller.cc b/engine/src/flutter/lib/ui/painting/image_decoder_impeller.cc index 4130f37e75..aa89551dc8 100644 --- a/engine/src/flutter/lib/ui/painting/image_decoder_impeller.cc +++ b/engine/src/flutter/lib/ui/painting/image_decoder_impeller.cc @@ -179,20 +179,19 @@ sk_sp ImageDecoderImpeller::UploadTexture( { auto command_buffer = context->CreateCommandBuffer(); - command_buffer->SetLabel("Mipmap Command Buffer"); if (!command_buffer) { FML_DLOG(ERROR) << "Could not create command buffer for mipmap generation."; return nullptr; } + command_buffer->SetLabel("Mipmap Command Buffer"); auto blit_pass = command_buffer->CreateBlitPass(); - blit_pass->SetLabel("Mipmap Blit Pass"); if (!blit_pass) { FML_DLOG(ERROR) << "Could not create blit pass for mipmap generation."; return nullptr; } - + blit_pass->SetLabel("Mipmap Blit Pass"); blit_pass->GenerateMipmap(texture); blit_pass->EncodeCommands(context->GetResourceAllocator()); @@ -233,6 +232,7 @@ void ImageDecoderImpeller::Decode(fml::RefPtr descriptor, io_runner = runners_.GetIOTaskRunner(), // result // ]() { + FML_CHECK(context) << "No valid impeller context"; auto max_size_supported = context->GetResourceAllocator()->GetMaxTextureSizeSupported(); diff --git a/engine/src/flutter/shell/platform/android/android_surface_vulkan_impeller.cc b/engine/src/flutter/shell/platform/android/android_surface_vulkan_impeller.cc index e4f5637d1e..f5bf383ab1 100644 --- a/engine/src/flutter/shell/platform/android/android_surface_vulkan_impeller.cc +++ b/engine/src/flutter/shell/platform/android/android_surface_vulkan_impeller.cc @@ -116,4 +116,9 @@ bool AndroidSurfaceVulkanImpeller::SetNativeWindow( return false; } +std::shared_ptr +AndroidSurfaceVulkanImpeller::GetImpellerContext() { + return impeller_context_; +} + } // namespace flutter diff --git a/engine/src/flutter/shell/platform/android/android_surface_vulkan_impeller.h b/engine/src/flutter/shell/platform/android/android_surface_vulkan_impeller.h index f5012dbf61..c96cbd21a8 100644 --- a/engine/src/flutter/shell/platform/android/android_surface_vulkan_impeller.h +++ b/engine/src/flutter/shell/platform/android/android_surface_vulkan_impeller.h @@ -40,6 +40,9 @@ class AndroidSurfaceVulkanImpeller : public AndroidSurface { // |AndroidSurface| bool ResourceContextClearCurrent() override; + // |AndroidSurface| + std::shared_ptr GetImpellerContext() override; + // |AndroidSurface| bool SetNativeWindow(fml::RefPtr window) override;