URLSession downloadTask with Resumable data causing Error Domain=NSPOSIXErrorDomain Code=14 "Bad address" in iOS 12
Originator: | rich | ||
Number: | rdar://44794214 | Date Originated: | 25/09/2018 |
Status: | Open | Resolved: | |
Product: | iOS | Product Version: | 12 |
Classification: | Bug | Reproducible: | Yes |
Area: Foundation Summary: When using an URLSession with Resumable data we are seeing the following errors: Error Domain=NSPOSIXErrorDomain Code=14 "Bad address" in iOS 12. Only happens iOS 12, downloads complete as expected in iOS 11 & 10. After inspecting the file system after the downloadTask has been cancelled, the file with the resumable data appears to be added to the file system correctly however the OS does not seem to be able to load this data with the downloadTask(withResumeData:) method. In the example project we are using an OperationQueue with Operations as this represents where we are seeing the error in our app however the error can be replicated by calling task.cancel(:) normally so does not appear related to the OperationQueue. Steps to Reproduce: 1. Create Operation with URLSession downloadTask, add to queue, start downloading file. 2. Cancel downloading, triggers save of resume data 3. Create Operation with resumable data, add to queue. 4. Error Domain=NSPOSIXErrorDomain Code=14 "Bad address" Expected Results: downloadTask(withResumeData:) to continue using resumable data and eventually complete successfully. Actual Results: downloadTask(withResumeData:) method returns the following error and download does not complete. 2018-09-26 13:56:35.538762+0100 ResumeDataExample[24928:2934196] Task <FE9372B8-44A5-4603-8B05-55211A66E9CF>.<2> finished with error - code: -1002 Error Domain=NSPOSIXErrorDomain Code=14 "Bad address" Version/Build: Xcode 10 / iOS 12
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!
temp solution
As temporary solution you may delete resumable data when you got error (and next attempt should be finish normally). I understand that this solution techically disabling resumable ability but at this time (21.Apr.2019) for iOS 12 no other solutions
completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) { if (error) { if ([error.domain isEqualToString: NSPOSIXErrorDomain] && (error.code == EFAULT)) { [[NSFileManager defaultManager] removeItemAtPath:resumeDataPath error:nil]; } } }
Did you resolve this issue? We are running into the same issue. Thanks.