Background NSURLSession not permitted to access app group sandbox
| Originator: | cs | ||
| Number: | rdar://18143721 | Date Originated: | 8/26/2014 |
| Status: | Open | Resolved: | |
| Product: | iOS | Product Version: | 8.0 beta 5 |
| Classification: | Reproducible: | Always |
Summary:
On device only, trying to make a new background NSURLSession from a today view extension logs sandbox permissions errors to the console and is unable to upload files. As outlined in the app extension programming guide, the sharedContainerIdentifier on the configuration used to create the URL session was set to the identifier of the app group. The app groups is enabled for and the app group ID is added to the app IDs of both the extension and the main app, and the corresponding values are in the app and appex entitlement files.
Furthermore, attempting to create upload tasks with the session fail with similar permissions errors logged. The error reported to URLSession:task:didCompleteWithError: is NSPOSIXErrorDomain -- code: 2. The same issues occur whether the items are done on a background thread or on the main thread.
Background upload works as expected on simulator.
Steps to Reproduce:
1. Create background NSURLSession with app group ID in sharedContainerIdentifier property of the configuration object.
2. Console logs report sandboxing errors.
3. Create upload tasks by sending the uploadTaskWithRequest:fromFile: message to the NSURLSession.
4. Console logs report more errors and uploads fail.
Expected Results:
I would expect the background NSURLSession to upload the files as it does in the simulator using the shared container.
Actual Results:
Upload fails on device due to permissions issues. Here are the relevant console logs:
Aug 26 19:47:01 iPhone-5S-1 com.getdropbox.DropboxExtensionTest.DropboxTodayView[383] <Error>: Failed to issue sandbox extension for file file:///private/var/mobile/Containers/Shared/AppGroup/93C71934-7BDF-45BB-9106-4FD0BC60756E/logPoolBeingUploadedByExtension/ios_iPhone6,1_8.0_3.2-b2_178ED533-49DA-46CE-B068-6495F092F25D_1409107621_ANALYTICS_0_849221010.log.extensionbackgroundupload, errno = 1
Aug 26 19:47:01 iPhone-5S-1 nsurlsessiond[113] <Error>: Error linking upload file: Error Domain=NSCocoaErrorDomain Code=257 "The operation couldn’t be completed. (Cocoa error 257.)" UserInfo=0x157e1ff20 {NSFilePath=/private/var/mobile/Containers/Shared/AppGroup/93C71934-7BDF-45BB-9106-4FD0BC60756E/logPoolBeingUploadedByExtension/ios_iPhone6,1_8.0_3.2-b2_178ED533-49DA-46CE-B068-6495F092F25D_1409107621_ANALYTICS_0_849221010.log.extensionbackgroundupload, NSUnderlyingError=0x157e1e1e0 "The operation couldn’t be completed. Operation not permitted"}
Aug 26 19:47:01 iPhone-5S-1 syncdefaultsd[388] <Notice>: (Note ) marked "com.me.keyvalueservice" topic as "enabled" on <APSConnection: 0x15e60f470>
Aug 26 19:47:01 iPhone-5S-1 syncdefaultsd[388] <Notice>: (Error) Process with pid 188 is not authorized to access com.apple.stocks
Aug 26 19:47:01 iPhone-5S-1 syncdefaultsd[388] <Notice>: (Note ) marked "com.me.keyvalueservice" topic as "opportunistic" on <APSConnection: 0x15e60f470>
Aug 26 19:47:01 iPhone-5S-1 kernel[0] <Notice>: 014466.168832 wlan0.A[339] AppleBCMWLANConfigManager::configureRoamingProfile(): Received new roaming profile 3 (was 3, flag=0x1)
Aug 26 19:47:01 iPhone-5S-1 nsurlsessiond[113] <Error>: __NSCFLocalDownloadFile: error 2 creating temp file: /private/var/mobile/Containers/Shared/AppGroup/93C71934-7BDF-45BB-9106-4FD0BC60756E/Library/Caches/com.apple.nsurlsessiond/Downloads/com.getdropbox.DropboxExtensionTest/CFNetworkDownload_m5yda0.tmp
Version:
iOS 8 beta 5
Notes:
Others on the developer forums seem to be having similar issues, and also report somewhat similar issues for OS 10.10. Here are a couple links for posts discussing this issue on iOS:
https://devforums.apple.com/message/1021058#1021058
https://devforums.apple.com/message/1030240#1030240
Configuration:
iPhone 5s 16GB, Verizon
Attachments:
Comments
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!