Audio playback does not start when the app stays in background

Originator:hideo.koide
Number:rdar://34128154 Date Originated:08/29/2017
Status:DUPLICATE/36138130/OPEN Resolved:
Product:iOS + SDK DUPLICATE OF 36138130 OPEN Product Version:iOS 11.x
Classification: Reproducible:Always
 
Area:
AVFoundation

Summary:
We develops iAP2 compatible accessory and iOS app for Automotive company.
The iOS app has a feature for audio playback. Audio playback can be controlled by commands sent from head unit via iAP2.

There is a case that the app is requested to start audio playback when the app is in background (The app can work in background by using iAP2). 
Although we understand that making a nonmixable audio session active while the app was in the background is not allowed, 
https://developer.apple.com/documentation/avfoundation/avaudiosessionerrorcode/avaudiosessionerrorcodecannotinterruptothers

the workaround described in the following url works until iOS10.
https://stackoverflow.com/questions/29036294/avaudiorecorder-not-recording-in-background-after-audio-session-interruption-end/29124425
----
I added the following

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
before configuring AVAudioSession and it worked. Still don't know what bugs may appear.
----

But unfortunately, that workaround does not work from iOS11. Is this the expected change of iOS11? If yes, is there another workaround to setActive of AudioSession from background app?

This app (and accessory) has been already sold as default service and head unit of the car sold in US market, a lot of users may be affected. Please kindly help of advice for our products. Thanks.

Steps to Reproduce:
1. Connect iPhone to the iAP2 accessory (headunit)
2. Startup the app on iPhone
3. Move the app to background
4. Headunit send therequest command for starting audio playback on the iPhone app

Expected Results:
The app should success to make setActive of AudioSession, then audio playback should be started

Observed Results:
The app fails to make setActive of AudioSession

Version:
iOS11 beta8

Notes:
This app (and accessory) has been already sold as default service and head unit of the car sold in US market, a lot of users may be affected. Please kindly help of advice for our products. Thanks.

Comments

Hideo Koide

March 19 2018, 3:22 PM

Could you clarify the latest status of this issue? We understand that some behaviors has been changed, but we expect more stable solution as the official iOS 11.3 release.

The followings are summary of behaviors on starting audio playback when the app is in background.

  • iOS 9.x: setActive(true) always successes.
  • iOS 10.x: setActive(true) successes, if beginReceivingRemoteControlEvents has been previously called.
  • iOS 11.0 ~ 11.2.6: setActive(true) always fails, even though beginReceivingRemoteControlEvents has been previously called. (As workaround we retries setActive(true) with AVAudioSessionCategoryOptionMixWithOthers.)
  • iOS 11.3 betas: setActive(true) always fails. Also calling endReceivingRemoteControlEvents on stopping playback caused the issue that next playback can not be started.
By hideo.koide at March 19, 2018, 6:26 a.m. (reply...)

Apple Developer Relations

February 13 2018, 5:47 PM

Engineering has determined that your bug report is a duplicate of another issue and will be closed.

The open or closed status of the original report your bug was duplicated to appears in a text box within the bug detail section of the bug reporter user interface. For security and privacy reasons, we don't provide access to the original bug yours was duped to.

If you have any questions or concerns, please update your report directly at this link: https://bugreport.apple.com/.

By hideo.koide at March 19, 2018, 6:26 a.m. (reply...)

Hideo Koide

October 3 2017, 6:13 PM

Thanks for looking at this issue. We have confirmed that this issue still occurs on iOS11.0.1, and we have attached console and sysdiagnose logs retrieved from iOS11.0.1 device.

Environment: iPhone 8 Plus (iOS 11.0.1)

Step: 1. Startup the app 2. 10:44:04 Start audio playback (controlled from the connected iAP accessory) 3. 10:44:10 Stop audio playback (controlled from the connected iAP accessory) 4. Move the app to the background 5. 10:44:21 Start audio playback (controlled from the connected iAP accessory)

Result: 5. Failed to activate AudioSession for non-mixable audio playback

By hideo.koide at March 19, 2018, 6:25 a.m. (reply...)

Apple Developer Relations

October 2 2017, 5:11 PM

Please verify this issue with the iOS 11.0.1 GM and update your bug report at https://bugreport.apple.com/ with your results.

iOS 11.0.1 GM (15A402/403) https://developer.apple.com/download/ Posted Date: Sep 26th, 2017

If the issue persists, please attach a new sysdiagnose captured in the latest build and attach it to the bug report. Thank you.

iOS sysdiagnose Instructions: https://developer.apple.com/services-account/download?path=/iOS/iOS_Logs/sysdiagnose_Logging_Instructions.pdf


For a complete list of logging instructions visit: https://developer.apple.com/bug-reporting/profiles-and-logs/

By hideo.koide at March 19, 2018, 6:25 a.m. (reply...)

Hideo Koide

September 14 2017, 7:16 PM

Another person from our company (Xevo Inc) has already filed the similar issue in #33527051, but it has been closed and we still do not understand the related specification fully. So please kindly confirm the following.

We understand as followings. Is this correct?

  • "now playing app" means that the app has succeed AVAudioSession#setActive() for non-mixable playback category and it can receive remote commands from ControlCenter.
  • When an app is in the background and it is not the the now playing app, there are no ways to make it to the now playing app.
  • There was the workaround (call beginReceivingRemoteControlEvents) until iOS10, but it is not available on iOS11.
By hideo.koide at March 19, 2018, 6:24 a.m. (reply...)

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!