twilio / twilio-voice-ios

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

Cellular call ends doesn't unhold the Twilio Voip Call #89

Closed softsan closed 2 years ago

softsan commented 2 years 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 start a voip call from user A to user B using call kit, sound is routed correctly. I receive a native (Cellular) call on user A. The user A choose "Hold & Answer" option, so the voip call will set on Hold while the Cellular call will be routed correctly. At some point of time the Cellular call is ended by the other party so I will try to unhold that voip call ongoing which is on hold at this time. but then then there is no audio at all. Also, when the Cellular call is ended also the "didDeactivateAudioSession" is called. If i go to the call kit ui , i see two calls (even the Cellular call is ended) and Cellular call has that "Hold" button pressed. So i can't unhold/hear any audio in my twilio Voip Call. I used following code to explicitly unhold my Voip Call when the cellular call is ended. Also i noted that if the cellular call is ended by me then the unhold part works just fine.

Steps to Reproduce

  1. [Step one]
  2. [Step two]
  3. [Insert as many steps as needed]

Code

public class CallObserverDelegate : CXCallObserverDelegate
    {
        CXCallController _callController;
        public void Init(CXCallController callController)
        {
            _callController = callController;

        }
        public override void CallChanged(CXCallObserver callObserver, CXCall call)
        {
            var activeCall = callObserver.Calls.FirstOrDefault();
            var cnt = callObserver.Calls.Count();
            if (activeCall == null) return;
            if(cnt==1 && activeCall.Uuid.Equals(AppDelegate.Instance.ActiveCallUUID))
            {
                if(activeCall.OnHold)
                {
                    // Build action
                    var holdCallAction = new CXSetHeldCallAction(activeCall.Uuid, false);

                    // Create transaction
                    var transaction = new CXTransaction(holdCallAction);

                    // Inform system of call request
                    // Send request to call controller
                    if (_callController == null) return;

                    _callController.RequestTransaction(transaction, (error) => {
                        // Was there an error?
                        if (error == null)
                        {
                            // No, report success
                            Console.WriteLine("Transaction request sent successfully.");
                        }
                        else
                        {
                            // Yes, report error
                            Console.WriteLine("Error requesting transaction: {0}", error);
                        }
                    });
                }
            }

        }
    }

Expected Behavior

It should unhold the twilio voip call and audio should be hearing at both party.

Actual Behavior

It doesn't unhold and no audio is available

Reproduces How Often

Everytime

Logs

// Log output when the issue occurs

Versions

All relevant version information for the issue.

Voice iOS SDK

6.3.0

Xcode

13.2.1

iOS Version

15.3

iOS Device

iPhone 11 pro max, IPhone XR

bobiechen-twilio commented 2 years ago

Thanks for reporting this @softsan .

We also found this one and identified that this started happening on iOS 15. We are investigating and hoping to provide fix in the sample app soon.

softsan commented 2 years ago

@bobiechen-twilio Hi Any updates/Suggestions on this? Thanks

bobiechen-twilio commented 2 years ago

Hi @softsan

While this is still an issue on iOS 15, we found that when the app receives the CallKit callback, you can enable the SDK audio device when unholding the call here: https://github.com/twilio/voice-quickstart-ios/blob/master/ObjcVoiceQuickstart/ViewController.m#L674. This should reactivate the audio session and audio should start flowing again.

Let us know how this works for you.

-bobie

softsan commented 2 years ago

HI @bobiechen-twilio It seems to be working fine. Thanks for the workaround. I have another inconsistent issue regarding one-way audio. e.g this is the callsid: CA6a2671f8f1f828375de221c3c58ffd77 where caller can hear the audio but receive can't.

bobiechen-twilio commented 2 years ago

Hi @softsan

Glad that the original issue has been resolved by the workaround. For the Call SID you provided, I did see a handful of constant audio input level warnings being raised during the call, but everything looks fine other than that. Did this also happen when testing the hold/unhold behavior?

Please set the SDK log level to DEBUG or above and check if there is any error/warning when the issue is happening.

softsan commented 2 years ago

@bobiechen-twilio

Did this also happen when testing the hold/unhold behavior?

No this is happened when the call is picked up. We see this issue with different customer in our prod. environment, but not able to reproduce in our local/dev environment, so can't debug. It is inconsistent.

softsan commented 2 years ago

@bobiechen-twilio Sorry to bug you again, but that enabling audio in PerformSetHeldCallAction works for outgoing call. but doesn't work for incoming call. Also does One-way audio issue have anything related to TVODefaultAudioDevice ?

Screenshot 2022-04-11 at 8 31 05 PM

like in your sample, audio is disabled at starting of a new call or at the time of answering a call. So does it make any impact?(in my case i do not disabled it anywhere) Also in my case, i declare that audio as static in my AppDelegate and use it in ProviderDelegate. So does it have any side effect?

bobiechen-twilio commented 2 years ago

Hi @softsan

It looks like the example code you are referring to was used for previous version of the SDK. In the latest sample app you only have to toggle the audio device in the CallKit audio session (de)activation callbacks: https://github.com/twilio/voice-quickstart-ios/blob/master/ObjcVoiceQuickstart/ViewController.m#L595

softsan commented 2 years ago

@bobiechen-twilio Thanks. Yeah i saw that in latest after I comment. So can this solve that one way audio issue?

I see many users in my prod environment facing this one way audio frequently.

softsan commented 2 years ago

@bobiechen-twilio this is sorted out, added code logic for Twilio Audio device enabled or disabled on CallKit's Audio session activate/deactivate, so, now closing this issue.