Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
shell/gpu: call Context virtuals instead of downcasting to ContextVK
impeller_context_ is a shared_ptr<impeller::Context> handed in by the caller, and
it is often a SurfaceContextVK, which derives from Context rather than ContextVK.
ContextVK::Cast on it is an unchecked downcast: DisposeThreadLocalCachedResources
then locks desc_pool_mutex_ at the wrong offset, pthread_mutex_lock returns
EINVAL, and the process aborts. The same member is cast to SurfaceContextVK a few
lines below, so the two casts could not both be right.

DisposeThreadLocalCachedResources, CreateCommandBuffer and GetCommandQueue are
all virtual on Context and SurfaceContextVK overrides or delegates them, so call
through the base and drop the casts.
  • Loading branch information
jwinarske committed Oct 6, 2026
commit 587a3467ab55e14bbc4d0e0b63b27f3017476595
9 changes: 3 additions & 6 deletions engine/src/flutter/shell/gpu/gpu_surface_vulkan_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ std::unique_ptr<SurfaceFrame> GPUSurfaceVulkanImpeller::AcquireFrame(
// Skipping it when the compositor presents would leave the raster thread
// holding those pools for the life of the engine.
if (impeller_context_) {
impeller::ContextVK::Cast(*impeller_context_)
.DisposeThreadLocalCachedResources();
impeller_context_->DisposeThreadLocalCachedResources();
}

// Nothing to acquire or present when an external view embedder owns
Expand Down Expand Up @@ -260,12 +259,10 @@ std::unique_ptr<SurfaceFrame> GPUSurfaceVulkanImpeller::AcquireFrame(
TRACE_EVENT0("flutter", "GPUSurfaceVulkan::PresentImage");

{
const auto& context = impeller::ContextVK::Cast(*impeller_context);

//----------------------------------------------------------------------------
/// Transition the image to color-attachment-optimal.
///
auto cmd_buffer = context.CreateCommandBuffer();
auto cmd_buffer = impeller_context->CreateCommandBuffer();

auto vk_final_cmd_buffer =
impeller::CommandBufferVK::Cast(*cmd_buffer).GetCommandBuffer();
Expand All @@ -286,7 +283,7 @@ std::unique_ptr<SurfaceFrame> GPUSurfaceVulkanImpeller::AcquireFrame(
return false;
}
}
if (!context.GetCommandQueue()->Submit({cmd_buffer}).ok()) {
if (!impeller_context->GetCommandQueue()->Submit({cmd_buffer}).ok()) {
return false;
}
}
Expand Down
Loading