NSPersistentCloudKitContainer causes crash on watchOS when device is offline

Hi. I'm hoping someone might be able to help us with an issue that's been affecting our standalone watchOS app for some time now.

We've encountered consistent crashes on Apple Watch devices when the app enters the background while the device is offline (i.e., no Bluetooth and no Wi-Fi connection). Through extensive testing, we've isolated the problem to the use of NSPersistentCloudKitContainer. When we switch to NSPersistentContainer, the crashes no longer occur.

Interestingly, this issue only affects our watchOS app. The same CloudKit-based persistence setup works reliably on our iOS and macOS apps, even when offline. This leads us to believe the issue may be specific to how NSPersistentCloudKitContainer behaves on watchOS when the device is disconnected from the network.

We're targeting watchOS 10 and above. We're unsure if this is a misconfiguration on our end or a potential system-level issue, and we would greatly appreciate any insight or guidance.

Can you share the crash log? Or file a feedback report with it attached and a sysdiagnose from the affected device?

TN3163: Understanding the synchronization of NSPersistentCloudKitContainer | Apple Developer Documentation

Hi, and thank you for the quick response. It's greatly appreciated!

Unfortunately, this crash does not appear to generate a crash log. However, we're able to reproduce it consistently on two separate Apple Watch devices.

  • When using NSPersistentCloudKitContainer and the device is offline (no Wi-Fi and no Bluetooth), the app crashes when entering the background.
  • If we switch to NSPersistentContainer, no crash occurs under the same conditions.
  • If the device is online, no crash occurs, even when using NSPersistentCloudKitContainer and allowing the app to enter the background.
  • If we keep the app in the foreground (e.g., by continuously tapping the screen), the app also does not crash, even when offline and using NSPersistentCloudKitContainer.

So in summary, the crash consistently occurs under the following three conditions:

  1. Using NSPersistentCloudKitContainer
  2. Device is offline (no Wi-Fi, no Bluetooth)
  3. App transitions to the background.

We would appreciate any insight, particularly if this might be a known limitation specific to watchOS that we need to work around. Thank you!

NSPersistentCloudKitContainer causes crash on watchOS when device is offline
 
 
Q