Many Background URL Sessions Cause Hang on Subsequent App Foregrounding
| Originator: | mliberatore09 | ||
| Number: | rdar://22273767 | Date Originated: | August 13th, 2015 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 8 - 9 |
| Classification: | Performance | Reproducible: | Always |
Summary: If you instantiate many NSURLSessions with a background configuration while the app is running. Once backgrounded, when foregrounded again if another instance of NSURLSession with a background configuration is created, e.g. NSURLSessionConfiguration *backgroundSessionConfiguration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:backgroundSessionIdentifier]; [NSURLSession sessionWithConfiguration:backgroundSessionConfiguration delegate:nil delegateQueue:nil] it will hang for several seconds. Use of the NSURLSession after instantiation is not required for the problem to occur. Steps to Reproduce: 1. Launch attached sample app on any device iOS 8 - 9. In -application:didFinishLaunchingWithOptions:, 100 instances of NSURLSession with a background configuration are created. 2. Lock the device. 3. Unlock the device, and immediately start pressing the button repeatedly. Notice that the main thread is blocked because on -applicationDidBecomeActive, the app tries to instantiate an NSURLSession with a background configuration, which takes several seconds to complete. Expected Results: The thread should not hang, and -sessionWithConfiguration: should return quickly. Its reasonable to expect that -sessionWithConfiguration: can be called on the main thread without hindering user experience. Actual Results: -sessionWithConfiguration: blocks the thread for several seconds, depending on the number of NSURLSessions instantiated while the app was previously in the foreground. Version: iOS 8 - iOS 9 Beta 5 Notes: This does not occur with NSURLSessions that do not use a background session configuration. Configuration: Any iOS device Attachments: https://dl.dropboxusercontent.com/u/46435935/URLSessionLocking.zip
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!