Lately we are experiencing some crashes / system terminations in our app, due to "exhausted real (wall clock) time allowance of 10.00 seconds".
I never was able to reproduce the issue, but my client states that it happened for him multiple times in a row. He sent me 2 crash reports, and both of them have the same structure:
- The main thread blocked in [HKHealthStore authorizationStatusForType:] / semaphore_wait_trap
- 'Elapsed total CPU time' high, while 'Elapsed application CPU time' very low (like 0.006, 0% CPU in the following report)
- He also sent me a 'wakeups report' together with the crash reports ("exceeding limit of 150 wakeups per second over 300 seconds"), maybe it can be related?
Did somebody encounter something similar or has any thoughts what could be the root cause?
Thank you very much in advance,
Full crash report attached.
I also attached a code snippet; the following method is called on the main thread when an alert controller is dismissed:
func saveCyclingDistanceWorkout(distance:Double, startDate:Date, endDate:Date, workoutMetadata: WorkoutMetadata, workoutRouteBuilder: Any? = nil, completion: ((Bool, NSError?) -> Void)? = nil) {
// Check if permission is still enabled for cycling distance, else show error
var shouldUseCyclingDistance = true
let cyclingDistanceAuthorizationStatus = healthStore.authorizationStatus(for: HKObjectType.quantityType(forIdentifier: HKQuantityTypeIdentifier.distanceCycling)!)
if cyclingDistanceAuthorizationStatus == .notDetermined || cyclingDistanceAuthorizationStatus == .sharingDenied {
shouldUseCyclingDistance = false
}
...