My app plays background audio using AVAudioPlayer and receives remote control events from iOS. Everything works fine while audio is playing, but if audio is paused and my app is moved into the background, something odd happens. If I use a bluetooth device to resume/unpause the audio after 10 minutes, iOS terminates my app with the following message:
<MyApp>[633] has active assertions beyond permitted time:
{(
<SBProcessAssertion: 0x25f520> identifier: com.apple.mediaremote.sendremotecommand process: <MyApp>[633] permittedBackgroundDuration: 600.000000 reason: finishTask owner pid:58
)}
There are two very odd things about this.
iOS will not shutdown my app right at the 10 minute mark. It will only do it after receiving remote control command via bluetooth.
If I use iOS's remote control buttons or the remote control on my headphones, my app will resume playing audio with no trouble.
I cannot figure out why a bluetooth remote control message would cause iOS terminate my app. I've been able to confirm that the Pandora app does not appear to have a similar problem.
Does anyone have a clue about this?
Update: Further testing reveals a clearer description of the bug. It appears that this forced iOS crash of the application happens when attempting to resume background audio after the audio has been paused for 10 minutes or more and the application has experienced a low memory warning.
The following steps are necessary to reproduce the bug:
- Either pause the application's audio and then send it to the background (hit the home button or switch to another app) or pause the application's audio while it is in the background
- Cause the application to experience a low memory warning (either simulated or real)
- After 10 mi开发者_如何学Cnutes attempt to play audio using a remote control event triggered from a device such as a Bluetooth device or speaker dock, etc.
Note: iOS only seems to force-crash the application when the final remote control event is initiated from an external device such as a Bluetooth device, speaker dock or car adapter. Using iOS's built-in "remote control" interface or remote controls on headphones do not appear to cause the crash.
Like George mentioned in the comments, I've been able to reproduce this with my own App, Pandora and at least one other audio-playing app. I've filed a bug report with Apple.
精彩评论