I have 3 Background Queue tasks running on app launch. They take approximately 25sec to complete. There is no memory issues, nor an issue with the tasks themselves, the tasks simply go through a database for filtering/reading data purposes (SQLite).
If I minimise the app whilst the tasks are running, the app is killed within 3sec, as any time I go back to the app after 3 sec the app starts again. I get the "Message from debugger: Terminated due to signal 9" as soon as I minimise the app. I use Swift and iOS14, is there a way to complete 30sec or less background SQLite DB tasks with the app not released from memory? Or just pause/kill the tasks to prevent killing the app?
I run my tasks using the DispatchQueue Extension:
extension DispatchQueue {
static func background(delay: Double = 0.0, background: (()->Void)? = nil, completion: (() -> Void)? = nil) {
DispatchQueue.global(qos: .background).async {
background?()
if let completion = completion {
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: {
completion()
})
}
}
}
static func backgroundFast(delay: Double = 0.0, background: (()->Void)? = nil, completion: (() -> Void)? = nil) {
DispatchQueue.global(qos: .default).async {
background?()
if let completion = completion {
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: {
completion()
})
}
}
}
}