twilio / twilio-voice-ios

Programmable Voice SDK by Twilio
https://www.twilio.com/voice
38 stars 14 forks source link

VoiceOver plays through earpiece after call has ended #121

Open mourke opened 7 months ago

mourke commented 7 months ago

Before filing an issue please check that the issue is not already addressed by the following:

Please ensure that you are not sharing any Personally Identifiable Information(PII) or sensitive account information (API keys, credentials, etc.) when reporting an issue.

Description

πŸ‘‹ I'm an iOS engineer at HubSpot. We are doing an accessibility audit of our app and we noticed that when a Twilio call is started (in the outbound direction) while VoiceOver is enabled, the VoiceOver voice is only playing through the earpiece during the call (this is expected), but when the call is ended, the voice continues to play through the earpiece instead of being routed back through the device speaker. We noticed that if we route the call through the device speaker (using AVAudioSession.overrideOutputAudioPort(.speaker)) before ending the call, the VoiceOver voice will be correctly played through the speaker when the call is ended. This leads me to believe that this is due to the AVAudioSession not being ended correctly (whether that be through .setActive(false) or some other method) when a call is completed.

Is this something that is expected for us (the caller of the framework) to have to do, or should it be on your end?

I originally thought that it could be an iOS issue, but I tried with the MobilePhone.app and with Instagram, and they both work correctly.

Steps to Reproduce

  1. Turn on VoiceOver
  2. Start Twilio call
  3. End call
  4. Observe how the VoiceOver voice is now only coming out of the earpiece

Expected Behavior

After ending a call with Twilio, the VoiceOver voice should be returned to how it was before (coming out of the speaker as well).

Actual Behavior

When the call is ended, the VoiceOver voice is now only coming out of the earpiece. Turning on and turning off VoiceOver doesn't fix this. Exiting the app will return VoiceOver to its original state.

Reproduces How Often

100%

Voice iOS SDK

6.3.1

Xcode

15.0

iOS Version

15,16,17

iOS Device

All iPhones

bobiechen-twilio commented 7 months ago

Hi @mourke

Thanks for reaching out. We will take a look at how our audio-device interacts with the AVAudioSession during call state changes and get back to you.

Quick question: is the app enabling and disabling the audio device when getting the CallKit didActivateAudioSession and didDeactivateAudioSession callbacks?

mourke commented 7 months ago

We will take a look at how our audio-device interacts with the AVAudioSession during call state changes and get back to you.

Perfect thank you!

Quick question: is the app enabling and disabling the audio device when getting the CallKit didActivateAudioSession and didDeactivateAudioSession callbacks?

Yes that's all we're doing in those callbacks.

private let audioDevice = DefaultAudioDevice()

...

func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
    audioDevice.isEnabled = true
}

func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
    audioDevice.isEnabled = false 
}