Contacts API Silent Failures

We’ve been attempting to reliably update contacts in iCloud and Gmail containers. Having tried several approaches (bulk writes, batched writes, one-by-one writes with sleeps in between, etc.), we’ve found flakiness in all approaches that is never exposed to the app.

Diving a little deeper, we’ve found that this appears to be due to internal server-client failures between iOS and the relevant CardDAV servers.

From our analysis, we seem to be seeing 2 key types of failure:

  1. When the client-server interaction is interrupted, contact update requests appear to be discarded and not resumed for whichever container was currently in progress.
  2. After a variable period of time, the server wipes the newer client state and reverts to an older, stale state.

We’re trying to understand if there is something we are doing wrong with our writes or if this is an iOS level bug.

This is easily reproducible for any device connected to an iCloud or Gmail account with circa. 100+ contacts:

  • for each container
    • for each contact in container
      • create CNSaveRequest
      • update any field in contact and add to save request
      • execute save request
Contacts API Silent Failures
 
 
Q