I have a music app that can play in the background, using AVQueuePlayer
. I'm in the process of adding support for CloudKit sync of the CoreData store, switching from NSPersistentContainer
to NSPersistentCloudKitContainer
.
The initial sync can be fairly large (10,000+ records), depending on how much the user has used the app. The issue I'm seeing is this:
-
✅ When the app is in the foreground, CloudKit sync uses a lot of CPU, nearly 100% for a long time (this is expected during the initial sync).
-
✅ If I AM NOT playing music, when I put the app in the background, CloudKit sync eventually stops syncing until I bring the app to the foreground again (this is also expected).
-
❌ If I AM playing music, when I put the app in the background, CloudKit never stops syncing, which leads the system to terminate the app after a certain amount of time due to high CPU usage.
Is there any way to pause the CloudKit sync when the app is in the background or is there any way to mitigate this?