iCloud accounts sometimes deadlocks causing [NSFileManager ubiquityIdentityToken] to fail

Originator:agiletortoise
Number:rdar://18702493 Date Originated:19-Oct-2014 08:13 AM
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 8.1b2 [18702493]
Classification:Crash Reproducible:Sometimes
 
Summary:
Some users are seeing a problem with their iCloud account on devices running iOS 8.1b2 (12B407).  

It appears after running for some amount of time, calls to iCloud become non-responsive. Specifically, [NSFileManager ubiquityIdentityToken] fails to return.

Apps calling [NSFileManager ubiquityIdentityToken] crash because the system terminates them for hanging the main thread.

If the user signs out of iCloud and signs back in, the issue goes away – at least for some amount of time, then usually returns.

I am aware of 6 users who have reported this problem and it has happen to me on my own iPad Air.  It seems to not be a device-linked problem, however.  Users reporting the issue continue to have use iCloud successfully on other devices, and reports have from different devices (iPads, iPhone 5s, iPhone 6 at least).

Steps to Reproduce:
Steps to have iCloud Account exhibit this problem are not known.  Once an account exhibits this problem, launch an app that calls [NSFileManager ubiquityIdentityToken] to determine if iCloud is available.

Expected Results:
[NSFileManager ubiquityIdentityToken] should quickly return a token on nil.

Actual Results:
[NSFileManager ubiquityIdentityToken] does not return, and the iOS system will terminate the app.

Version:
iOS 8.1b2 [12B407]

Notes:


Configuration:
Any

Attachments:

Comments

Appears to impact Apple code as well. Non-responsive when attempting the user-level task of signing out of iCloud for the main account. Sign out taking over 20 minutes and not completing. Then a reboot, and sign out and sign in executes normally... for a while...

While debugging my own code, I happened upon this treatment of "Blocks" and there are strong hints of a connection to the symptoms we are seeing described across the net on problems with iCloud...

http://sealedabstract.com/code/nsnotificationcenter-with-blocks-considered-harmful/

And while the example is using NSNotificationCenter, the author does make note of other APIs using blocks and similar side effects:

“Whenever I try to take a picture, the lens doesn’t open.” “If I go to Screen A, leave it, and come back, the button on Screen B does something really strange.” “After I pick a photo from my photo library, the app works fine. For about 20 seconds. Then it crashes. But I can only reproduce this once per testing session. I have to wait until tomorrow to catch it again.”

Not a smoking gun (yet) but the typical and very subtle negative side effects of using Blocks are a good possibility. I started down this path with problems in syncing notes, contacts and otherwise in iCloud... with just the system apps, not even my own code.

https://developer.apple.com/library/ios/documentation/CloudKit/Reference/CKContainer_class/index.html

  • (void)discoverAllContactUserInfosWithCompletionHandler:(void (^)(NSArray userInfos, NSError error))completionHandler

Bet a coffee that this or something similar in CloudKit usage is coping with erroneous re-calls into the completion handlers... Maybe not. Regardless, the "self deprecating" problem that Blocks create through the local-global "feature" is a charlie foxtrot.

By williamcerniuk at Nov. 2, 2014, 4:21 p.m. (reply...)

Still reproducible in iOS8.1 (12B410) release.

Here is a stack:

0 libsystem_kernel.dylib 0x00000001940cceb8 semaphore_wait_trap + 8

1 libdispatch.dylib 0x0000000193fb2d98 dispatchgroup_wait_slow + 244

2 CloudDocs 0x0000000189577818 -[BRXPCSyncProxy resultWithTimeout:] + 72

3 CloudDocs 0x0000000189563614 +[BRAccount _refreshCurrentLoggedInAccountForcingRefresh:error:] + 328

4 CloudDocs 0x00000001895637cc +[BRAccount currentCachedLoggedInAccountWithError:] + 48

5 CloudDocs 0x000000018957ba28 LBCopyUbiquityAccountToken + 52

6 Foundation 0x0000000183c8aab0 -[NSFileManager ubiquityIdentityToken] + 60

7 AppName 0x00000001000b96e0 -[UbiquityContainerWatcher userIdentityToken]

By constantine at Oct. 27, 2014, 8:33 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!