aramusss
aramusss

Reputation: 2401

iOS CloudKit is slow on querying heavy CKAsset (even with QoS)

I am using CloudKit to download CoreML (machine learning) models. They are about 90MB each. I have the public database and default zone with one custom 'ML' record type. I query this 'ML' by id, and it takes more than a minute to get a response on the completion block (it should be a matter of seconds). I've tried production environment, setting quality of service, and different ways of querying with the same result (very slow).
I wonder if I'm missing something or if there is any other way of downloading the ML models that is faster?

Here's my current code:

let arrayPredicate = NSPredicate(format: "id == %@", id)
let query = CKQuery(recordType: "ML", predicate: arrayPredicate)


let queryOperation = CKQueryOperation(query: query)
queryOperation.qualityOfService = .userInteractive
queryOperation.resultsLimit = 1
queryOperation.recordFetchedBlock = { record in
  // This gets called +60 sec after
}

queryOperation.queryCompletionBlock = { record, error in
  // Same here
}

publicDB.add(queryOperation)

Upvotes: 2

Views: 245

Answers (1)

aramusss
aramusss

Reputation: 2401

I switched to Firebase Storage to test and the result was slightly faster, but not much faster. rmdaddy and TommyBs were right on their line of thought: CloudKit might be a bit slower because you need to query a record, but the download is on a similar speed.

My final solution was so use Firebase Storage as it's easy to handle download progress and then show it on UI for the user to wait.

Upvotes: 2

Related Questions