`didActivateAudioSession` not consistently called by CallKit.

We have identified following audio interruption scenarios by a PSTN call when there is an active VOIP call.

Initial Steps:

  1. Voip call is active.
  2. Incoming PSTN call.
  3. CallKit displays the option to Hold & Accept (Hold the Voip call and Accept the PSTN call).
  4. Select the Hold & Accept options, PSTN call is now active and Voip call is in hold.


Scenario 1:

User action

End the PSTN call from CallKit.

CallKit action

CallKit automatically resumes the Voip call and audio is flowing.

Result - Pass

didActivateAudioSession is invoked we know exactly when to start audio again.


Scenario 2:

User action

While the PSTN call is active manually switch to the Voip app and Resume the call.

CallKit action

PSTN call is put on hold by CallKit and Voip call is active.

Result - Pass

didActivateAudioSession is invoked we know exactly when to start audio again.


Scenario 3:

User action

In CallKit menu use the Swap button to switch between the Voip call and PSTN call.

CallKit action

CallKit switches between the calls by putting the active call on hold.

Result - Fail

didActivateAudioSession is invoked we know exactly when to start audio again and audio flows properly but sometimes when siwtching between call the CallKit just sends the performEndCallaction to the Voip app instead of putting the Voip call on Hold.

Not sure if this is because Hold action by the Voip app taking more than x amount of time which leads to CallKit ending the Voip call.


Scenario 4:

User action

Let the PSTN call end on its own.

CallKit action

CallKit launches the Voip app and call is in hold. User is expected to manually resume the call from the Voip app.

Result - Fail

No audio is flowing as didActivateAudioSession is not invoked at all. There was a previous call to didDeactivateAudioSession. Even if we manually resume the call without waiting for didActivateAudioSession we fail to get the audio device instance audio::apple::deviceResumeFailed.

Can this be fixed by Apple to invoke the didActivateAudioSession or am i doing something wrong here ?


Tested on

  1. Model : iPhone SE2
  2. iOS Version: 16.1

Scenario 3 I have figured out that if performSetHeldCallAction with onHold is true, does not respond with action fulfill (or action fail) within roughly 5 seconds then performEndCallAction is called. This makes sense when incoming PSTN call needs to be accepted asap. For us as of now the stopping of audio and performing the hold operation does go beyond 5 seconds.

`didActivateAudioSession` not consistently called by CallKit.
 
 
Q