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

[Impeller] Don't use waitUntilScheduled on iOS #40768

Merged
merged 3 commits into from
Mar 30, 2023
Merged
Changes from all commits
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
21 changes: 21 additions & 0 deletions impeller/renderer/backend/metal/command_buffer_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,28 @@ static bool LogMTLCommandBufferErrorIfPresent(id<MTLCommandBuffer> buffer) {
}

[buffer_ commit];

#if (FML_OS_MACOSX || FML_OS_IOS_SIMULATOR)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment with some context about what we know and have tried to date, and what the failure mode is and how to trigger it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alrighty, done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any instructions on how to reproduce the issue seen? E.g. Run wonderous app on a simulator on an arm mac host?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thats pretty much exactly it.

// We're using waitUntilScheduled on macOS and iOS simulator to force a hard
// barrier between the execution of different command buffers. This forces all
// renderable texture access to be synchronous (i.e. a write from a previous
// command buffer will not get scheduled to happen at the same time as a read
// in a future command buffer).
//
// Metal hazard tracks shared memory resources by default, and we don't need
// to do any additional work to synchronize access to MTLTextures and
// MTLBuffers on iOS devices with UMA. However, shared textures are disallowed
// on macOS according to the documentation:
// https://developer.apple.com/documentation/metal/mtlstoragemode/shared
// And so this is a stopgap solution that has been present in Impeller since
// multi-pass rendering/SaveLayer support was first set up.
//
// TODO(bdero): Remove this for all targets once a solution for resource
// tracking that works everywhere is established:
// https://github.com/flutter/flutter/issues/120406
[buffer_ waitUntilScheduled];
#endif

buffer_ = nil;
return true;
}
Expand Down