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

Accepted Reply

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?

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

    Ok, good to know, thanks!

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

    Yeah, I ended up playing with Multipeer Connectivity framework and it works great for my particular use-case here.

    Is your simulator signed in to an iCloud account?

    Yes (in fact I have to sign into my account on the simulator every 24hrs... is this a bug?) - and I am under the impression that push notifications don't work at all in the simulator, and there are docs (I'm pretty sure?) that say CloudKit sync notifs aren't supported on simulator.. so I'm surprised you seems to be indicating that it should work on sim?

  • Wow yikes, sorry for the above formatting. Tried to quote your replies and respond, but the forums just mashed all the lines together. Hope it makes sense.

  • Thanks for the clarification. It's a terrible delay for any modern application. I wanted to avoid Firebase but their speed is blazing fast.

Add a Comment

Replies

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?

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

    Ok, good to know, thanks!

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

    Yeah, I ended up playing with Multipeer Connectivity framework and it works great for my particular use-case here.

    Is your simulator signed in to an iCloud account?

    Yes (in fact I have to sign into my account on the simulator every 24hrs... is this a bug?) - and I am under the impression that push notifications don't work at all in the simulator, and there are docs (I'm pretty sure?) that say CloudKit sync notifs aren't supported on simulator.. so I'm surprised you seems to be indicating that it should work on sim?

  • Wow yikes, sorry for the above formatting. Tried to quote your replies and respond, but the forums just mashed all the lines together. Hope it makes sense.

  • Thanks for the clarification. It's a terrible delay for any modern application. I wanted to avoid Firebase but their speed is blazing fast.

Add a Comment