diff --git a/shell/platform/android/android_surface_vulkan_impeller.cc b/shell/platform/android/android_surface_vulkan_impeller.cc index 61fc5bfec2899..939570904338c 100644 --- a/shell/platform/android/android_surface_vulkan_impeller.cc +++ b/shell/platform/android/android_surface_vulkan_impeller.cc @@ -24,6 +24,8 @@ AndroidSurfaceVulkanImpeller::AndroidSurfaceVulkanImpeller( auto& context_vk = impeller::ContextVK::Cast(*android_context->GetImpellerContext()); surface_context_vk_ = context_vk.CreateSurfaceContext(); + eager_gpu_surface_ = + std::make_unique(surface_context_vk_); } AndroidSurfaceVulkanImpeller::~AndroidSurfaceVulkanImpeller() = default; @@ -46,6 +48,14 @@ std::unique_ptr AndroidSurfaceVulkanImpeller::CreateGPUSurface( return nullptr; } + if (eager_gpu_surface_) { + auto gpu_surface = std::move(eager_gpu_surface_); + if (!gpu_surface->IsValid()) { + return nullptr; + } + return gpu_surface; + } + std::unique_ptr gpu_surface = std::make_unique(surface_context_vk_); diff --git a/shell/platform/android/android_surface_vulkan_impeller.h b/shell/platform/android/android_surface_vulkan_impeller.h index 7c5296c180dd3..d348d51b47970 100644 --- a/shell/platform/android/android_surface_vulkan_impeller.h +++ b/shell/platform/android/android_surface_vulkan_impeller.h @@ -11,6 +11,7 @@ #include "flutter/shell/platform/android/android_context_vulkan_impeller.h" #include "flutter/shell/platform/android/surface/android_native_window.h" #include "flutter/shell/platform/android/surface/android_surface.h" +#include "shell/gpu/gpu_surface_vulkan_impeller.h" namespace flutter { @@ -49,6 +50,11 @@ class AndroidSurfaceVulkanImpeller : public AndroidSurface { private: std::shared_ptr surface_context_vk_; fml::RefPtr native_window_; + // The first GPU Surface is initialized as soon as the + // AndroidSurfaceVulkanImpeller is created. This ensures that the pipelines + // are bootstrapped as early as possible. + std::unique_ptr eager_gpu_surface_; + bool is_valid_ = false; FML_DISALLOW_COPY_AND_ASSIGN(AndroidSurfaceVulkanImpeller);