WatchOS AVSpeechSynthesizer, Snapshot watchdog transgression.

I collect a lot of crash logs seem like this, but it seems that users are not affected by these crashes.

How it happened? I find a clue about this,
Code Block swift
libAXSpeechManager.dylib 0x6e31adbc -[AXSpeechThread main] + 368 (AXSpeechThread.m:50)

All crashes has Text to Speech function. my related code:

Code Block swift
   func speak(_ announcement: String,preDelay:TimeInterval = 0, endDelay:TimeInterval = 0,lan:String = "", rate:Float = AVSpeechUtteranceDefaultSpeechRate,didFinish:((_ str:String)->Void)? = nil) {
    DispatchQueue.global(qos: .background).async {
       
      let utterance = AVSpeechUtterance(string: announcement.lowercased())
      utterance.volume = 2.0
      if(lan.count > 0){
        utterance.voice = AVSpeechSynthesisVoice(language:lan)
      }
      utterance.preUtteranceDelay = preDelay
      utterance.postUtteranceDelay = endDelay
      utterance.rate = rate
       
      if let callback = didFinish {
        self.synth.speakUtterance(utterance){
          synth,utt in
          callback("\(utt.speechString)")
        }
      } else {
        self.synth.speak(utterance)
      }
    }
  }


AVSpeechSynthesizer in watchOS seems easy to cause bugs.
Any suggest ? Thank you for help.



Code Block language
Incident Identifier: 235EFDB7-B276-4EA6-9FA8-4D624017F1EA
CrashReporter Key: a52074c6e7cd936048b907e2e6eec067f1578b41
Hardware Model: Watch2,6
Process: YaoYao WatchKit Extension [408]
Path: /private/var/containers/Bundle/Application/0841E854-BF20-4E7A-8BB0-5FB99B3F289D/YaoYao WatchKit App.app/PlugIns/YaoYao WatchKit Extension.appex/YaoYao WatchKit Extension
Identifier: hltek.YaoYao.watchkitapp.watchkitextension
Version: 2 (2.2.7)
AppVariant: 1:Watch2,6:6
Code Type: ARM (Native)
Role: Non UI
Parent Process: launchd [1]
Coalition: hltek.YaoYao.watchkitapp.watchkitextension [423]
Date/Time: 2020-06-14 08:40:35.2580 +0800
Launch Time: 2020-06-14 08:38:42.0000 +0800
OS Version: Watch OS 6.2.5 (17T608)
Release Type: User
Baseband Version: n/a
Report Version: 104
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: CAROUSEL, Snapshot watchdog transgression. Exhausted CPU time allowance of 2.00 seconds. Elapsed total CPU time (seconds) 6.22 (user 6.22, system 0.00), 60% CPU. Elapsed application CPU time (seconds) 2.48, 25% CPU.
Termination Description: SPRINGBOARD, CSLSceneSnapshotAction watchdog transgression: xpcservice<hltek.YaoYao.watchkitapp.watchkitextension>:408:408 exhausted CPU time allowance of 2.00 seconds | <FBExtensionProcess: 0x15ad8e90; xpcservice<hltek.YaoYao.watchkitapp.watchkitextension>:408:408; typeID: com.apple.watchkit> Elapsed total CPU time (seconds): 6.220 (user 6.220, system 0.000), 62% CPU | Elapsed application CPU time (seconds): 2.484, 25% CPU, lastUpdate 2020-06-14 00:40:29 +0000
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x4243b6f8 semaphore_wait_trap + 8
1 libdispatch.dylib 0x422f7188 _dispatch_sema4_wait + 12 (lock.c:139)
2 libdispatch.dylib 0x422f7612 _dispatch_semaphore_wait_slow + 104 (semaphore.c:132)
3 FrontBoardServices 0x45a4f576 -[FBSSceneSnapshotRequestHandle performRequestForScene:] + 418 (FBSSceneSnapshotRequestHandle.m:67)
4 FrontBoardServices 0x45a53b5c -[FBSSceneSnapshotAction snapshotRequest:performWithContext:] + 218 (FBSSceneSnapshotAction.m:168)
5 FrontBoardServices 0x45a0f070 -[FBSSceneSnapshotRequest performSnapshotWithContext:] + 276 (FBSSceneSnapshotRequest.m:65)
Thread 6 name:
Thread 6:
0 libsystem_kernel.dylib 0x4243b6a8 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x4243ad7a mach_msg + 42 (mach_msg.c:103)
2 CoreFoundation 0x4277a4a0 CFRunLoopServiceMachPort + 106 (CFRunLoop.c:2575)
3 CoreFoundation 0x4277649a CFRunLoopRun + 1026 (CFRunLoop.c:2931)
4 CoreFoundation 0x42775dfc CFRunLoopRunSpecific + 326 (CFRunLoop.c:3192)
5 Foundation 0x43057a58 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 180 (NSRunLoop.m:374)
6 libAXSpeechManager.dylib 0x6138adbc -[AXSpeechThread main] + 368 (AXSpeechThread.m:50)
7 Foundation 0x43158308 NSThreadstart__ + 708 (NSThread.m:724)
8 libsystem_pthread.dylib 0x424c9236 _pthread_start + 130 (pthread.c:896)
9 libsystem_pthread.dylib 0x424cff50 thread_start + 20
[crash 1](https://developer.apple.com/forums/content/attachment/e45cca8c-69bf-4c9a-adef-2f42458844e7){: .log-attachment}







WatchOS AVSpeechSynthesizer, Snapshot watchdog transgression.
 
 
Q