Pressing End&Answer button on reception of second audio call results in no audio

Number:rdar://49726681 Date Originated:09.04.2019
Status:Open Resolved:
Product:iOS+SDK Product Version:iOS12
Classification:Bug Reproducible:Always
To reproduce, Apple's SpeakerBox demo application needs to be modified to simulate CPU load by adding these lines of code into CallViewController viewDidLoad:

// MARK: simulate CPU load, 15 threads to reliably reproduce the issue
for _ in 1..<15 {
	Thread.detachNewThread {
		while true {

and after performing steps described below, it results in no audio in app. As it has been discovered, after pressing End&Answer button in original SpeakerBox app, AVAudioSessionInterruptionNotification notification (with AVAudioSessionInterruptionTypeBegan) comes first, and provider:didActivateAudioSession: notification comes last, so audio is started. But in modified SpeakerBox app, provider:didActivateAudioSession comes first and AVAudioSessionInterruptionNotification comes last, so audio unit becomes stopped, which results in no audio. And what is important, there is no AVAudioSessionInterruptionNotification with AVAudioSessionInterruptionTypeEnded at all, so audio is not restarted.
Thus, one of problem exists in iOS:
- Thread coordination issue. When CPU becomes loaded, provider:didActivateAudioSession and AVAudioSessionInterruptionNotification come into app in wrong order as they sent to main thread queue from different threads
- Missing AVAudioSessionInterruptionNotification with AVAudioSessionInterruptionTypeEnded

Steps to Reproduce:
1. Compile and install modified SpeakerBox demo app.
2. Simulate incoming call and answer
3. Simulate second incoming call and press End & Answer

Expected Results:
App should have audio

Actual Results:
No audio can be heard

Was able to reproduce the issue with iOS 12.1 and iOS 12.2
Was not able to reproduce on iOS 11


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at 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!