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:
- QOS_CLASS_DEFAULT
- QOS_CLASS_USER_INITIATED
- QOS_CLASS_UTILITY
- QOS_CLASS_BACKGROUND
- QOS_CLASS_UNSPECIFIED
- QOS_CLASS_USER_INTERACTIVE
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")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…