From 84ab745e06e45a8341de782d7c9cd5e9b12d78a7 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 5 Nov 2019 19:14:26 -0600 Subject: [PATCH] Launch BGTaskScheduler on a background thread --- iOS/AppDelegate.swift | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/iOS/AppDelegate.swift b/iOS/AppDelegate.swift index 75db8252b..dfa3eec88 100644 --- a/iOS/AppDelegate.swift +++ b/iOS/AppDelegate.swift @@ -317,10 +317,15 @@ private extension AppDelegate { func scheduleBackgroundFeedRefresh() { let request = BGAppRefreshTaskRequest(identifier: "com.ranchero.NetNewsWire.FeedRefresh") request.earliestBeginDate = Date(timeIntervalSinceNow: AppDefaults.refreshInterval.inSeconds()) - do { - try BGTaskScheduler.shared.submit(request) - } catch { - os_log(.error, log: self.log, "Could not schedule app refresh: %@", error.localizedDescription) + + // We send this to a background 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 { + do { + try BGTaskScheduler.shared.submit(request) + } catch { + os_log(.error, log: self.log, "Could not schedule app refresh: %@", error.localizedDescription) + } } }