Anyone had experience diagnosing these crashes? I have a single user getting them consistently, and though I found an iOS related post, my app is not crashing on the same ty
Rewrite Shaybc's answer in Swift 3:
DispatchQueue.global(qos: .background).async {
// some task to perform
print("This is my task")
})
Reason:
in iOS / tvOS there are queues / threads, each thread has its own type or priority also known as a "quality of service" or for short "QOS", which means the level of urgency that the cpu should handle this thread, the possibilities are:
once you run too many tasks at the same time in the same queue, then the OS notifies you that it cannot perform all this tasks at the same time in the same priority (there is a limit to the size of the stack for each queue), there for it says "OverCommit", which means you have over committed the queue (in your case the "Default-QOS" queue) and it exits since it cannot receive more tasks at this time and execute them at the fashion you want.
solution:
what you should do is first find the "dispatch_async" command that causes this crash, then use one of the other queues (it means expecting slower response then expected for that task),
usually developer don't think about it and simply use main queue which is the default priority / queue like this:
dispatch_async(dispatch_get_main_queue()) {
// some task to perform
print("This is my task")
}
in order to fix this (if the app notifies you that you have overcommitted the main queue) is to change it to one of the other queues like this:
let qualityOfServiceClass = QOS_CLASS_BACKGROUND
let backgroundQueue = dispatch_get_global_queue(qualityOfServiceClass, 0)
dispatch_async(backgroundQueue, {
// some task to perform
print("This is my task")
})
if you do not require a background (or parallel) execution, you can even ignore the dispatch_async command altogether and simply execute you commands like this:
// some task to perform
print("This is my task")
For Swift 3 use:
DispatchQueue.global(qos: DispatchQoS.QoSClass.background).async {
// ...
}