diff --git a/src/dawn_native/metal/DeviceMTL.mm b/src/dawn_native/metal/DeviceMTL.mm index 9bd4fea36b..3846d0d480 100644 --- a/src/dawn_native/metal/DeviceMTL.mm +++ b/src/dawn_native/metal/DeviceMTL.mm @@ -357,7 +357,16 @@ namespace dawn_native { namespace metal { void Device::WaitForCommandsToBeScheduled() { SubmitPendingCommandBuffer(); - [*mLastSubmittedCommands waitUntilScheduled]; + + // Only lock the object while we take a reference to it, otherwise we could block further + // progress if the driver calls the scheduled handler (which also acquires the lock) before + // finishing the waitUntilScheduled. + NSPRef> lastSubmittedCommands; + { + std::lock_guard lock(mLastSubmittedCommandsMutex); + lastSubmittedCommands = mLastSubmittedCommands; + } + [*lastSubmittedCommands waitUntilScheduled]; } MaybeError Device::WaitForIdleForDestruction() {