dispatch_group_leave快速崩溃 [英] dispatch_group_leave crash in swift

查看:554
本文介绍了dispatch_group_leave快速崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这种情况很少发生。这是堆栈跟踪的最后一行:

This happens very rarely. Here is the last line of the stack trace:

0  libdispatch.dylib              0x0000000197a85a9c dispatch_group_leave + 48

dispatch_group_leave在一个完全闭包中被调用,该闭包的调用方式如下:

dispatch_group_leave is called in a complete closure which is invoked like this:

  dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
                { () -> Void in
                    let query = HKStatisticsCollectionQuery(quantityType: quantityType,
                        quantitySamplePredicate: nil,
                        options: statisticOptions,
                        anchorDate: anchorDate,
                        intervalComponents: interval)
                    query.initialResultsHandler = {

                        complete()

所以我们分派到后台线程,运行HKStatisticsCollectionQuery,然后调用一个名为complete的函数参数闭包。在complete内部,将调用dispatch_group_leave并发生崩溃。

So we dispatch to a background thread, run a HKStatisticsCollectionQuery, and then call a function parameter closure called complete. Inside complete is where the dispatch_group_leave is called and the crash happens.

任何想法都值得赞赏!
谢谢!

Any ideas are most appreciated! Thanks!

推荐答案

如果 dispatch_group_leave 调用不是与 dispatch_group_enter 保持平衡,则可能会发生崩溃。

If dispatch_group_leave call isn't balanced with dispatch_group_enter then crash may happen.

这篇关于dispatch_group_leave快速崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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