twilio / voice-quickstart-ios

Twilio Voice Quickstart for iOS with Swift
MIT License
179 stars 95 forks source link

No in-call audio after first call #31

Closed miken01 closed 7 years ago

miken01 commented 7 years ago

When I make a call for the first time after my app launches everything works great. I am able to connect to the other end and I can hear audio on both sides. However, if I end the call and then try to call back, then I do not hear any audio while inside the call. I am able to connect on both ends just as I would expect, but I just hear no audio. Also, all of the provider delegates that we respond to to start the audio are in fact called.

My question here is should I be calling TwilioVoice.sharedInstance().stopAudioDevice() within the provider(_ provider: CXProvider, perform action: CXEndCallAction) delegate and call TwilioVoice.sharedInstance().startAudioDevice() within the provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) delegate every time we make a call?

Thanks

bobiechen-twilio commented 7 years ago

Hi @miken01

I am sorry that you are experiencing the audio problem with the SDK. Could you provide us the Voice SDK logs when the audio problem is happening in you app?

And yes, you will have to call the startAudioDevice and stopAudioDevice methods at appropriate timing since the SDK needs to properly deactivate the audio device and re-configure it next time the call is established, as the CallKit framework expects.

Let me know if this helps.

-bobie Twilio SDK Engineering 9am - 6pm Pacific Time

miken01 commented 7 years ago

Hi Bobbie,

Yes I'd be happy to send those logs your way, but I do not see any such log in my documents or library directory of the app. Is there a setting I need to enable in order to generate the log file you are requesting?

Thanks

bobiechen-twilio commented 7 years ago

Hi @miken01

Don't worry. Could you add this line in you application and make sure it gets executed before making/accepting calls?

  TwilioVoice.sharedInstance().logLevel = .verbose

This way the SDK will start print out debug logs into Xcode console window and you can attach it in case you run into trouble using the SDK in the future.

Thanks -bobie

miken01 commented 7 years ago

Hi Bobbie,

I have enabled verbose logging and have replicated the issue. I have attached the log. Many thanks for the help!

Twilio Verbose.txt

bobiechen-twilio commented 7 years ago

Hi @miken01

Thanks for getting the log for us the SDK logs and I've checked it though I could find any immediate errors in it indicating the no-audio problem that you described. I will need to ask you a couple of questions:

Thanks -bobie

miken01 commented 7 years ago
  1. 2.0.0-beta9

  2. I haven't had a chance to test this exact issue on the Swift Quickstart. One thing to note is I have copied the code nearly verbatim and verified all areas surrounding the SDK are the exact same. Down to the comments talking about the iOS issue where audio doesn't always start correctly. The only deviations are areas where I grab data unique to my app such as the recipients name and VoIP identity.

  3. The last two had the no audio issue. The first two worked correctly. Usually, this occurs after the first call is completed, but this case the second call worked. The third and forth did not.

  4. When running this test I have two iPhones in my hands, and I put them both to my ear to hear for audio. In these scenarios the caller is an iPhone 7 Plus running iOS 10.3.1 and the recipient is an iPhone 6 running iOS 10.2.1.

Thanks

miken01 commented 7 years ago

Hi Bobie,

I just wanted to check to see if you've been able to replicate the issue and/or come up with a solution? My client is getting very agitated as we're waiting on this to be resolved to push to the App Store. Any help you can provide here would be greatly appreciated.

Thanks!

bobiechen-twilio commented 7 years ago

Hi @miken01

We've pulled in the ticket to investigate the no-audio issue into this week. Sorry for keeping you waiting and please bear with us.

Will keep you updated once we have anything findings.

-bobie

miken01 commented 7 years ago

Hi @bchen-twilio

Do you have any updates for this issue and an estimate as to when it'll be resolved? As I stated before we have an app that is ready for production and just waiting for this issue to be resolved before submitting to the App Store.

Also, have you guys herd of anyone else having an issue like this before? I just feel that if this is a legitimate issue with the SDK then other developers would be having the same exact issue. Makes me concerned I'm just missing something in my configuration, but every time I review the code it matches the quick start project exactly.

Thanks

bobiechen-twilio commented 7 years ago

Hi @miken01

Sorry for keeping you waiting, but unfortunately we still have hard trying to reproduce and debug the no-audio issue. Though we are not seeing other SDK users reporting exactly the same symptom and steps, but we definitely are seeing similar no-audio issues being reported by SDK users once in a while and we do treat this with the highest priority.

I've been checking the log you sent me but so far I don't notice any immediate error on the SDK side showing audio device failure. I then started investigating the SIP signaling and media negotiation part of the log but it does require me some extra time since I am not the expert and I need to reach out to the backend service team for their help.

I am curious if the same no-audio issue happens in your environment without integrating CallKit?

Apologize again for keeping you waiting.

-bobie

miken01 commented 7 years ago

Hi @bchen-twilio

Ok I understand. Hopefully, you guys are able to find a solution or at least a cause soon. My client is getting very impatient, and we're getting to a point where the only option we'll have is to yank this SDK and find a new vender very soon as the is holding up the app launch. I would rather not do that as it would mean I would have to spend dozens of unpaid hours to integrate a new solution, but that would be better than loosing my client.

I have not tried to use the SDK without CallKit as we have a requirement to use CallKit and the client will not relent on this. Especially when other apps such as Skype, WhatsApp and others all use CallKit with seemingly no issues. At least not one so reproducible as this one is.

I am going to spend some time today and tomorrow working on using your sample project with my backend to see if that has the same issue. I'll let you know if it does.

Thanks

lottadot commented 7 years ago

We have seen this too, with the 2.0b {8/9} SDK's. We were under the assumption it was something in our code that's causing it (simply because that's how things typically seem to play out using vendor's SDK's). I need to loop back to the raw kickstart project code, put our app info into it, w/ two hard coded unique tokens and see if I can get that code to exhibit it too.

miken01 commented 7 years ago

Hi @bchen-twilio

I have downloaded the Swift quick start example from your GitHub and modified it to call my backend to get the call access token. I have also modified it to use my app's App ID so the CallKit VoIP push notifications work. After doing this I have been able to test the failing scenario and replicate the issue with your sample application.

If you can provide me with a non-public method to transfer the files to you I'd be happy to send you the code and steps to replicate. Hopefully, this example will allow you to replicate the issue. I am also available to hop on a phone call to walk you through the steps to replicate if you'd like.

Also, I have installed the latest build 2.0.0-beta10 and the problem still exists.

Thanks

bobiechen-twilio commented 7 years ago

Hi @miken01

Thanks for giving it a try. Yes, I would definitely love to try your code. You should be able to find my email address in the profile page.

While I was working on this issue I found two potential theories that could cause the no-audio problem:

Let me know. -bobie

miken01 commented 7 years ago

Hi @bchen-twilio

I have sent you an email with a Dropbox link to the sample project. There are also instructions on how to launch the app and replicate the issue. Please send any replies to this thread so we can keep the history whole.

For your two theories I'll take a look to see if the AVAudioSessionInterruptionNotification notification is called when the issue occurs and let you know. I'm not able to test with both phones on cellular as I only have one SIM card for my carrier.

One thing I will note is that it shouldn't really matter if I'm on Wi-Fi or not. I'm testing on a home network and my router has pretty much factory settings. I could understand having connection issues if I were on a corporate network with some crazy firewall settings and rules, but the setup I have here is very much the same setup most end-users are going to have. With that said Skype, WhatsApp and every other VoIP service I've used works without failure. Also, Apple Push Notifications work by sending UDP packages and I don't ever notice issues there. I guess my point is I highly doubt the issue is with my Wi-Fi setup is all.

Thanks for the help!

bobiechen-twilio commented 7 years ago

Thanks @miken01 got your email and will take a look.

Keep you updated.

miken01 commented 7 years ago

Hi @bchen-twilio

No worries. I understand there are limitations and you are just trying to rule out different factors. My thought was simply it shouldn't matter is all.

Anyways, I just tried with one phone on cellular and one on Wi-Fi and got the issue to occur. It succeeded twice and then failed on the third attempt.

Thanks

bobiechen-twilio commented 7 years ago

Thanks for understanding @miken01

Interesting... not the first or the second call, but the third or later ones. Did it happen again on the wifi one?

miken01 commented 7 years ago

It happens regardless of being both on Wi-Fi or one one Wi-Fi and one cellular. Also, sometimes it happens on the second call but sometimes it takes a few attempts before the issue happens.

bobiechen-twilio commented 7 years ago

Hi @miken01

I found a way to reproduce the no-audio issue (assuming CallKit enabled) - disconnect the call and right away make another one, before provider:didDeactivateAudioSession: is called. This more or less explains why the no-audio issue happens intermittently. If I wait until the CallKit has deactivated the audio session, then audio flows for the next call.

It would be great if you can confirm my experiment and theory. Unfortunately there is no magic to query if the AVAudioSession has been deactivated or not, but at least we can add an CallKit-integration API like audioSessionDeactivated for the application to call so that the SDK can keep the state and make sure audio for the subsequent calls works.

Let me know if this helps. Thanks for being patient with us.

-bobie

miken01 commented 7 years ago

Hi @bchen-twilio

I had thought that before so I do make sure to wait a good five seconds before making another call. I have put breakpoints in the provider:didDeactivateAudioSession: method just to be sure it's being called and then making a call after it runs. Doing this I still am able to replicate the issue.

Also, the issue isn't intermittent in nature. It happens every single time I make subsequent calls. The only intermittent aspect is if the issue occurs on the second, third or fourth call. Regardless, it always happens.

Honestly, I feel like somewhere in the SDK you guys are holding onto the audio device or something. Perhaps, there is a memory leak that prevents the singleton from letting go of the audio device. These are just speculations but hopefully it'll help.

Thanks

miken01 commented 7 years ago

Hi @bchen-twilio

One other thing to keep in mind is the library seems to have several memory leaks that occur after ending a call. Perhaps this has something to do with the issue and would to a degree explain why it takes a few attempts before the issue happens. Please see screenshot below.

screen shot 2017-06-09 at 11 00 59 am

Thanks

bobiechen-twilio commented 7 years ago

Hi @miken01

Yes, we are aware of this one. There is a memory leak caused by the SSL library and we have a ticket in our radar.

Could you provide us the SDK log when the no-audio issue is still happening even with waiting for the did-deactivate-audio callback?

Thanks. -bobie

ryantxr commented 7 years ago

I would like to add that my app is experiencing exactly this issue. Everything appears to connect properly but I get no audio. I opened a ticket with Twilio and I am working through it with the engineer assigned. I will be monitoring this thread.

miken01 commented 7 years ago

Hi @bchen-twilio

I don't see what a new log is going to tell you different. I've always waited a fair amount of time to make a new call. The delegate callback is made within two seconds of ending a call. I usually wait at least five. Also, I have given you guys a codebase that is able to replicate the issue consistently. It may take a few tries to get it to happen but it always happens.

At this time I cannot spend more of my time giving you debugging information that you can easily obtain on your own by testing the sample code I sent you. Please use the resources I've already given you all to replicate the issue and solve the problem with the SDK.

I know my message here comes off very harsh, but please understand I am at my whits end with this issue. I communicated the problem to you all nearly a month ago, I have spent dozens of un-paid hours to provide you all with more than enough debugging information to replicate and resolve the problem, and now after a month we're right where we started with you asking for more information. I cannot believe you are all holding this as a high priority issue at this time. Which begs the question are the engineers behind the SDK actually looking at this thread or are we stuck at tier two support?

Lastly, my client has informed me that you all will have until the end of the week to resolve this issue or we will have no choice but to pull it from our app and use another vendor for VoIP calls. I would imagine other developers will follow suit if this critical issue is not resolved.

Thanks

goldsmith commented 7 years ago

@miken01 which vendor did you switch to? extremely frustrated with twilio sdk and support as well.

bobiechen-twilio commented 7 years ago

Hi @goldsmith,

Bobie here from the SDK team and we are sorry that you are experiencing frustration with the Voice iOS SDK. I saw that you opened a ticket #38 to report crash with the SDK but unfortunately we can't really reproduce the same issue. We'll keep investigating around the surface area where the crash happened and try to get back to you soon as we found the fix. Please bear with us.

Hey @miken01, How are things? Though we are actively working on fixing the TwiML issue but I am assuming now the no-audio issue has been fixed with the latest SDK beta. Let's close this ticket and create another ticket if you run into any issue in the future. Thanks!

-bobie

goldsmith commented 7 years ago

@bchen-twilio, I just sent you an email. it is not just the crash and in-call audio after multiple calls that aren't working for us.

jmclachlan commented 2 years ago

I am now having this exact issue but only on one phone. The same install works fine on other phones. But my personal iPhone 13 Pro which I use for development and testing only works on the first call. Then there is no audio and the microphone does not pick up anything. If I close the app out of memory and restart it, then it works again for just one call. This app has been working great for a year during development and then this issue started. I am not sure if it was when I updated to the latest Voice ask or when I upgraded iOS to 15.5. But again on other phones it works fine and in the simulator. I am trying to find another way to replicate it on a different device but it is consistent every time on my personal phone. I event erased the phone and restored it but nothing helps.