From 461468e14f2e665d16ae1cc217e7aaf49b19fe4d Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Wed, 6 Nov 2019 16:47:33 -0600 Subject: [PATCH] Dispatch the background task request on a dedicated serial queue. Issue #1180 --- iOS/AppDelegate.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/iOS/AppDelegate.swift b/iOS/AppDelegate.swift index dfa3eec88..8d2956606 100644 --- a/iOS/AppDelegate.swift +++ b/iOS/AppDelegate.swift @@ -18,6 +18,8 @@ var appDelegate: AppDelegate! @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, UnreadCountProvider { + private var bgTaskDispatchQueue = DispatchQueue.init(label: "BGTaskScheduler") + private var waitBackgroundUpdateTask = UIBackgroundTaskIdentifier.invalid private var syncBackgroundUpdateTask = UIBackgroundTaskIdentifier.invalid @@ -318,9 +320,9 @@ private extension AppDelegate { let request = BGAppRefreshTaskRequest(identifier: "com.ranchero.NetNewsWire.FeedRefresh") request.earliestBeginDate = Date(timeIntervalSinceNow: AppDefaults.refreshInterval.inSeconds()) - // We send this to a background queue because as of 11/05/19 on iOS 13.2 the call to the + // We send this to a dedicated seria queue because as of 11/05/19 on iOS 13.2 the call to the // task scheduler can hang indefinitely. - DispatchQueue.global(qos: .background).async { + bgTaskDispatchQueue.async { do { try BGTaskScheduler.shared.submit(request) } catch {