Termination notifications not properly sent/handled for foreground/active app on Power Off
| Originator: | mbabin | ||
| Number: | rdar://16633967 | Date Originated: | 16-Apr-2014 10:56 AM |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 7.1 (11D167) |
| Classification: | Bug | Reproducible: | Always |
Summary: For an iOS app that needs to perform a brief clean-up task when the application is terminated, has an application delegate that implements applicationWillTerminate:, and has one or more objects that are registered for the UIApplicationWillTerminateNotification, when the app is running in the foreground (active) and the user powers off the device (hold down lock button, slide to power off) the delegate method and/or notification methods are not called (or SIGKILL is received immediately after call, before any methods are allowed to run). The same problem does not occur if the app is running in the background on the device when powered off. The delegate method and notification methods are called and allowed to complete. The app in question allows the user to record audio. Recording can take place while the app is in the background or foreground. The methods which run on application termination (delegate or notification) are brief. If recording audio, the recording is stopped and the recording file is moved to a different location. The latter action (moving to a different location) could be foregone if necessary. If the recording is not stopped, the audio file is left in an unusable state (AVAudioRecorder). The user's data is lost. Steps to Reproduce: 1. Launch iOS app. 2. Start recording audio (press "Record" button). 3. Press and hold lock button on device. 4. Slide the "slide to power off" slider. Expected Results: Application delegate's -applicationWillTerminate: method and UIApplicationWillTerminateNotification notification handlers for other object(s) will be called and allowed to complete (within the usual "you have a few seconds to finish or your process will be killed" restriction). Actual Results: The application delegate's -applicationWillTerminate: method is either not called or is just entered when SIGKILL is received. The UIApplicationWillTerminateNotification notification handlers are not called.
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!