Core Data + CloudKit sync latency

Hello!

I am writing an app to sync data between an iPad app and an AppleTV app using Core Data + CloudKit. A brief overview of the functionality is:

  • I draw a doodle on my iPad using PencilKit
  • Tap a button to "save" the doodle
  • I generate jpg data [0] from the PencilKit canvas and save it in a Data attribute of an entity in Core Data (this data is ~30kb big)
  • The entry syncs to iCloud and is then displayed on the TV app after it syncs down

The issue is that this sync'ing usually takes around 15 seconds from the time I tap the "save" button to the time the doodle appears on the TV. I'm trying to make an interactive app I can play with my kids, and this delay will kind of be a mood killer. It doesn't have to be instantaneous, but anything < 5 seconds would be fine.

Right now I am only editing the same doodle over and over, so there is only one row in the entire database.

If I tap "save" on the iPad and then immediately background/foreground the TV app (which triggers a sync), the updated doodle appears in ~2 seconds, so I know the data is making it to/from iCloud very quickly.

  1. Is there a way to reduce this sync latency in the normal case?
  2. Is there a better strategy I should be using to magically send data between an iPad app and a TV app? (I still want to ultimately have it backed by Core Data to save all the doodles)
  3. I have push notifications enabled, and I presume they are working b/c the doodle sync only happens on my Apple TV hardware and not the simulator, but I'm not sure how else to determine whether the remote push is working?

Thank you for your time!

-Chad E


[0]: tvOS doesn't have PencilKit, so I can't save the PKDrawing data directly

Answered by Frameworks Engineer in 679044022

Is there a way to reduce this sync latency in the normal case?

No. In fact 15s is pretty good for end to end with CloudKit.

Is there a better strategy I should be using to magically send data between an iPad app and a TV app? (I still want to ultimately have it backed by Core Data to save all the doodles)

Near real time use cases can use GameKit or similar for faster communication latencies between proximal devices.

I have push notifications enabled, and I presume they are working b/c the doodle sync only happens on my Apple TV hardware and not the simulator, but I'm not sure how else to determine whether the remote push is working?

Is your simulator signed in to an iCloud account?

Accepted Answer

Is there a way to reduce this sync latency in the normal case?

No. In fact 15s is pretty good for end to end with CloudKit.

Is there a better strategy I should be using to magically send data between an iPad app and a TV app? (I still want to ultimately have it backed by Core Data to save all the doodles)

Near real time use cases can use GameKit or similar for faster communication latencies between proximal devices.

I have push notifications enabled, and I presume they are working b/c the doodle sync only happens on my Apple TV hardware and not the simulator, but I'm not sure how else to determine whether the remote push is working?

Is your simulator signed in to an iCloud account?

Core Data + CloudKit sync latency
 
 
Q