From f193b6da1ab23511f386f5e59627b612a6940532 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Wed, 29 Apr 2020 15:36:28 -0500 Subject: [PATCH] Prevent deadlocks by notifying group completion on background thread --- Frameworks/Account/CloudKit/CloudKitZone.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Frameworks/Account/CloudKit/CloudKitZone.swift b/Frameworks/Account/CloudKit/CloudKitZone.swift index 3486ab6f1..af8f91e1f 100644 --- a/Frameworks/Account/CloudKit/CloudKitZone.swift +++ b/Frameworks/Account/CloudKit/CloudKitZone.swift @@ -456,11 +456,15 @@ extension CloudKitZone { } } - group.notify(queue: DispatchQueue.main) { + group.notify(queue: DispatchQueue.global(qos: .background)) { if errorOccurred { - completion(.failure(CloudKitZoneError.unknown)) + DispatchQueue.main.async { + completion(.failure(CloudKitZoneError.unknown)) + } } else { - completion(.success(())) + DispatchQueue.main.async { + completion(.success(())) + } } }