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

查看:1578
本文介绍了一致的调度队列: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天全站免登陆