diff --git a/impeller/renderer/backend/metal/surface_mtl.mm b/impeller/renderer/backend/metal/surface_mtl.mm index 9b06878b76f78..05eec4964b49d 100644 --- a/impeller/renderer/backend/metal/surface_mtl.mm +++ b/impeller/renderer/backend/metal/surface_mtl.mm @@ -153,6 +153,20 @@ return IRect::MakeSize(resolve_texture_->GetSize()); } +static bool ShouldWaitForCommandBuffer() { +#if ((FML_OS_MACOSX && !FML_OS_IOS) || FML_OS_IOS_SIMULATOR) + // If a transaction is present, `presentDrawable` will present too early. And + // so we wait on an empty command buffer to get scheduled instead, which + // forces us to also wait for all of the previous command buffers in the queue + // to get scheduled. + return true; +#else + // On Physical iOS devices we still need to wait if we're taking a frame + // capture. + return [[MTLCaptureManager sharedCaptureManager] isCapturing]; +#endif // ((FML_OS_MACOSX && !FML_OS_IOS) || FML_OS_IOS_SIMULATOR) +} + // |Surface| bool SurfaceMTL::Present() const { if (drawable_ == nil) { @@ -179,17 +193,12 @@ } } -#if ((FML_OS_MACOSX && !FML_OS_IOS) || FML_OS_IOS_SIMULATOR) - // If a transaction is present, `presentDrawable` will present too early. And - // so we wait on an empty command buffer to get scheduled instead, which - // forces us to also wait for all of the previous command buffers in the queue - // to get scheduled. - id command_buffer = - ContextMTL::Cast(context.get())->CreateMTLCommandBuffer(); - [command_buffer commit]; - [command_buffer waitUntilScheduled]; -#endif // ((FML_OS_MACOSX && !FML_OS_IOS) || FML_OS_IOS_SIMULATOR) - + if (ShouldWaitForCommandBuffer()) { + id command_buffer = + ContextMTL::Cast(context.get())->CreateMTLCommandBuffer(); + [command_buffer commit]; + [command_buffer waitUntilScheduled]; + } [drawable_ present]; return true;