一致的调度队列:com.apple.root.default-qos.overcommit 崩溃 [英] Consistent Dispatch queue: com.apple.root.default-qos.overcommit crash

查看:45
本文介绍了一致的调度队列:com.apple.root.default-qos.overcommit 崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都有诊断这些崩溃的经验吗?我有一个用户始终如一地获取它们,虽然我找到了与 iOS 相关的帖子,但我的应用程序并没有因相同类型的操作而崩溃...

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 type of operation...

推荐答案

原因:

在 iOS/tvOS 中有队列/线程,每个线程都有自己的类型或优先级,也称为服务质量"或简称QOS",表示 CPU 应处理此线程的紧急程度,可能性有:

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

一旦您在同一个队列中同时运行了太多任务,操作系统就会通知您它不能以相同的优先级同时执行所有这些任务(堆栈大小有一个限制每个队列),其中显示OverCommit",这意味着您已过度提交队列(在您的情况下为Default-QOS"队列)并且它退出,因为它此时无法接收更多任务并以时尚方式执行它们你想要的.

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.

解决方案:

您应该首先找到导致此崩溃的dispatch_async"命令,然后使用其他队列之一(这意味着该任务的响应速度比预期的慢),

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")
})

如果您不需要后台(或并行)执行,您甚至可以完全忽略 dispatch_async 命令并简单地执行如下命令:

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")

这篇关于一致的调度队列:com.apple.root.default-qos.overcommit 崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆