Skip to content
This repository

iCloud Time Out #358

gazolla opened this Issue · 7 comments

3 participants

Sebastiao Gazolla Jr bcyng Saul Mora
Sebastiao Gazolla Jr

I started an app test to use Core Data and iCloud (using Magical Records). After a lot of troubles to configure Provisioning Profiles and Entitlements, the app finally runs. After a while the app crash and throw this message:

2012-12-31 03:42:07.079 iCloudTest[252:1103] -[PFUbiquitySafeSaveFile waitForFileToUpload:](268): CoreData: Ubiquity:  <PFUbiquityPeerReceipt: 0x1cd5a420>(0)
permanentLocation: <PFUbiquityLocation: 0x1cd57b30>: /private/var/mobile/Library/Mobile Documents/MA5BADG5AW~com~gazapps~iCloudTest/mobile.4088E03C-763E-5A81-BB1B-64CABAFA73E3/com.gazapps.iCloudTest/v8GumdiUYmkE0aO9iGtPTPHX07qqWk7kRytsQwHKjwU=/receipt.0.cdt
safeLocation: <PFUbiquityLocation: 0x1cd57a80>: /private/var/mobile/Library/Mobile Documents/MA5BADG5AW~com~gazapps~iCloudTest/mobile.4088E03C-763E-5A81-BB1B-64CABAFA73E3/com.gazapps.iCloudTest/v8GumdiUYmkE0aO9iGtPTPHX07qqWk7kRytsQwHKjwU=/mobile.4088E03C-763E-5A81-BB1B-64CABAFA73E3.0.cdt
currentLocation: <PFUbiquityLocation: 0x1cd57a80>: /private/var/mobile/Library/Mobile Documents/MA5BADG5AW~com~gazapps~iCloudTest/mobile.4088E03C-763E-5A81-BB1B-64CABAFA73E3/com.gazapps.iCloudTest/v8GumdiUYmkE0aO9iGtPTPHX07qqWk7kRytsQwHKjwU=/mobile.4088E03C-763E-5A81-BB1B-64CABAFA73E3.0.cdt

kv: (null)

Safe save failed for file, error: Error Domain=NSCocoaErrorDomain Code=512 "The file upload timed out." UserInfo=0x1cd5b7d0 {NSLocalizedDescription=The file upload timed out.}
2012-12-31 03:42:07.083 iCloudTest[252:1103] +[MagicalRecord(ErrorHandling) defaultErrorHandler:](0xe5ac0) Error: The file upload timed out.
2012-12-31 03:42:07.085 iCloudTest[252:1103] +[MagicalRecord(ErrorHandling) defaultErrorHandler:](0xe5ac0) Error Message: The file upload timed out.
2012-12-31 03:42:07.086 iCloudTest[252:1103] +[MagicalRecord(ErrorHandling) defaultErrorHandler:](0xe5ac0) Error Domain: NSCocoaErrorDomain
2012-12-31 03:42:07.087 iCloudTest[252:1103] +[MagicalRecord(ErrorHandling) defaultErrorHandler:](0xe5ac0) Recovery Suggestion: (null)
2012-12-31 03:42:07.089 iCloudTest[252:907] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x3a7702a3 0x3465f97f 0x3a6bae8d 0xdd453 0x38a6311f 0x38a624b7 0x38a671bd 0x3a743f3b 0x3a6b6ebd 0x3a6b6d49 0x38a842eb 0x338f62f9 0xd101d 0x37f22b20)
libc++abi.dylib: terminate called throwing an exception

I used this method to setup Core Data Stack:

[MagicalRecord setupCoreDataStackWithiCloudContainer:@"" localStoreNamed:@"PersonDB.sqlite"];

Anyone ever had this problem?

OSX 10.8.2,
Xcode 4.5.2,
app -> iOS 6,
device -> iPhone 4S
Sebastiao Gazolla Jr

iCloud Time Out (cont...)

The error occurs on NSPersistentStoreCoordinator+MagicalRecord.m


- (void) MR_addiCloudContainerID:(NSString *)containerID contentNameKey:(NSString *)contentNameKey localStoreNamed:(NSString *)localStoreName cloudStorePathComponent:(NSString *)subPathComponent completion:(void(^)(void))completionBlock;

in that point:

        dispatch_async(dispatch_get_main_queue(), ^{
            if ([NSPersistentStore MR_defaultPersistentStore] == nil)
here !  ====>> [NSPersistentStore MR_setDefaultPersistentStore:[[self persistentStores] objectAtIndex:0]];
            if (completionBlock)
            NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
            [notificationCenter postNotificationName:kMagicalRecordPSCDidCompleteiCloudSetupNotification object:nil];

The error message for this line (last line on stack) :

2012-12-31 13:18:57.206 iCloudTest[10186:907] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'
Sebastiao Gazolla Jr

This is the answer I received from Tom Harrington in :

Yes, more times than I care to recall.

What this means is that Core Data's internals failed to connect to iCloud in some obscure and undocumented way. There's no recovery path or fix-- you just get to try again later. Those errors don't come from Magical Record or your code, they're an internal Core Data / iCloud failure.

Here's the thing: This does not mean you did something wrong. And the corollary of that is, there is nothing you can do to fix it. When using iCloud with Core Data, this just happens sometimes, and you just have to deal with it. File a bug and pray to whatever god or gods you believe in that they fix it some day. Core Data with iCloud is just fundamentally flaky and you're encountering one of the most maddening parts.

Sometimes it helps to just try the call again. But Magical Record returns void, so detecting failure in code is not as simple as you might hope.

During testing, it might help to delete all of your app's data from iCloud, to start clean. You do this in iOS at Settings --> iCloud --> Storage & Backup --> Manage Storage --> (your app name here) --> Edit --> Delete All. Also be sure to check out to see what's present in the cloud. Also, when you're having problems, be sure to delete your app from the device so that no old data is sitting around.


Rather than closing this and trying to explain to our customers that they have to delete all their data and start again, can we put some exception handling in setupCoreDataStackWithiCloudContainer around MR_addiCloudContainerID that tries again, or make setupCoreDataStackWithiCloudContainer return an error or something so we can handle it in our app.

Basically the Tom Harrington solution above is basically just to not use magical record for iCloud - which doesn't really make sense.

not sure but this might be related to #362

Saul Mora
Sebastiao Gazolla Jr

Hi bcyng,

I understand that Tom Harrington said that this problem is not related to MagicalRecord as he said:

" Those errors don't come from Magical Record or your code, they're an internal Core Data / iCloud failure. "

That's the reason I closed this issue.


Can't we catch the NSRangeException repackage it into something more developer friendly and pass it up through MR_addiCloudContainerID and MR_setupCoreDataStackWithiCloudContainer so the app can then do something or maybe try it again?

Am I missing something here?

I mean these types of (icloud time out, icloud screwed up) errors have been coming out of iCloud since iOS5, and this stuff is run over inherently unreliable networks, we should really be handling them even though they are cryptic....

Saul Mora
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.