Can I get notified when my watchOS app is terminated by the system (e.g. watchdog)?

Hi all,

I’m developing a watchOS app and have seen cases where the app is terminated by the system — for example, due to CPU usage limits being exceeded (watchdog termination). Here’s a portion of one of the crash reports:

Exception Type:  EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: CAROUSEL 2343432205 
<RBSTerminateContext| domain:10 code:0x8BADF00D explanation:[app<app_name>:898] Failed to terminate gracefully after 5.0s
ProcessVisibility: Foreground
ProcessState: Running
WatchdogEvent: process-exit
WatchdogVisibility: Foreground
WatchdogCPUStatistics: (
"Elapsed total CPU time (seconds): 11.280 (user 9.800, system 1.480), 100% CPU",
"Elapsed application CPU time (seconds): 5.162, 46% CPU"
) reportType:CrashLog maxTerminationResistance:Interactive>

My questions:

1.) Is there any way to get notified (via Crashlytics, Xcode Organizer, or any other reporting mechanism) when this type of system-level termination happens — similar to how we’re notified of crashes?

2.)Is there any way for a watchOS app to receive runtime warnings from the system when it’s about to exceed CPU or memory limits — similar to UIApplication.didReceiveMemoryWarningNotification on iOS?

Thanks in advance!

Take a look at the Hangs and Launches reports in the Xcode Organizer, you may get some further info about these events there, if the customers experiencing them have opted in to sharing those analytics with you. Terminations like these won't show up in the Crashes section of the Xcode Organizer, as your app didn't crash, it was terminated by the system for exceeding the listed runtime threshold.

As to getting a warning for when you you're about to run out of time, there is no notification for these types of events. If such a notification were available, you'd likely observe for it from the main thread. However, your main thread was busy for a 5 second stretch, so you wouldn't even be able to receive the notification until your main thread was free enough to receive the event.

— Ed Ford,  DTS Engineer

Can I get notified when my watchOS app is terminated by the system (e.g. watchdog)?
 
 
Q