This happens very rarely. Here is the last line of the stack trace:
0 libdispatch.dylib 0x0000000197a85a9c dispatch_group_leave + 48
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()
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!
If dispatch_group_leave
call isn't balanced with dispatch_group_enter
then crash may happen.