Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
[Impeller] Use final cmd buffer to present drawable. (#46023)
Browse files Browse the repository at this point in the history
If we're not running with a transaction then we don't need to block on waitUntilScheduled on any platform. I think this should always work, as the problems we had before were due to always using drawable present. But this helper method schedules the drawable presentation after the cmd buffer is scheduled - which is what we're doing with waitUntilScheduled anyway - just non blocking from our perspective.

Fixes flutter/flutter#131520
  • Loading branch information
jonahwilliams authored and harryterkelsen committed Oct 23, 2023
1 parent 8592ce2 commit f8effca
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions impeller/renderer/backend/metal/surface_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,22 @@
}

if (drawable_) {
TRACE_EVENT0("flutter", "waitUntilScheduled");
id<MTLCommandBuffer> command_buffer =
ContextMTL::Cast(context.get())
->CreateMTLCommandBuffer("Present Waiter Command Buffer");
[command_buffer commit];
[command_buffer waitUntilScheduled];
[drawable_ present];
// If the threads have been merged, or there is a pending frame capture,
// then block on cmd buffer scheduling to ensure that the
// transaction/capture work correctly.
if ([[NSThread currentThread] isMainThread] ||
[[MTLCaptureManager sharedCaptureManager] isCapturing]) {
TRACE_EVENT0("flutter", "waitUntilScheduled");
[command_buffer commit];
[command_buffer waitUntilScheduled];
[drawable_ present];
} else {
[command_buffer presentDrawable:drawable_];
[command_buffer commit];
}
}

return true;
Expand Down

0 comments on commit f8effca

Please sign in to comment.