react-native-incall-manager icon indicating copy to clipboard operation
react-native-incall-manager copied to clipboard

[IOS] Audio sometimes doesn't work when used with WebRTC connection

Open kjhyun824 opened this issue 3 years ago • 14 comments

HI.

I'm building an app and have some issue. Here is my scenario.

// Establish WebRTC Connection
InCallManager.start({ media: 'video', auto: true });
// Communicate through RTC Connection

// After all communications done
InCallManager.stop();

// Re-establish WebRTC Connection 
InCallManager.start({ media: 'video', auto: true });

Here is problem. When I re-establish the connection and start InCallManager again, the Audio doesn't works at all, i.e. Mic input and Speaker output.

My assumption is due to IOS AVAudioSession, because WebRTC assumes that it's the only one controls AVAudioSession which is implemented as a singleton.

Am I right? and how can I fix it? (or do you have any plan for fixing it?)

React-Native-IncallManager Version : v3.3.0 libWebRTC : M84

kjhyun824 avatar Dec 15 '20 05:12 kjhyun824

I'm not 100% sure what solved it for me but what I did was got got it working with video and audio on. I included onicecandidate handlers to handle those messages as I was missing those before. Then once it was all perfect I removed the video parameter and it is still working great.

tgreco avatar Dec 24 '20 12:12 tgreco

So I take back what I said, this only works if I am on the same WiFi for some reason.

tgreco avatar Jan 07 '21 21:01 tgreco

@tgreco What did you handled on onicecandidate function? (i.e. which one was missing?) I also have tested on the same WIFI but it doesn't work for me... T.T

kjhyun824 avatar Jan 08 '21 01:01 kjhyun824

@kjhyun824

When the ICE candidates are received I use websockets to so send them over to the other user.

onIceCandidate(evt)
  {
    console.log('On Ice Candidate', evt.candidate);
    if(evt.candidate !== null)
    {
      WebsocketClient.GetInstance().sendIceCandidate(evt.candidate, WebRtcClient.#instance.#partnerUserId.toString());
    }
  }

Then when the websocket message is received on the other client side:

peerConnection.addIceCandidate(new RTCIceCandidate(candidate));

tgreco avatar Jan 08 '21 11:01 tgreco

I have the same issue. When I start a second call after close the first, I don't have sound...

jsellam avatar Jan 19 '21 16:01 jsellam

Same, only on ios, android works perfectly, if you have a solution share it here :)

flhember avatar Jan 21 '21 16:01 flhember

@tgreco Sorry for my late reply. In my case, I use Open WebRTC Toolkit(a.k.a. OWT) which offers WebRTC gateway and SDKs for implementing client-side application. And in the Client-side SDK, I have found the implementation that you have mentioned above. Moreover, if the ice connection was a problem, the Android should not work too, but it works... :(

I think it's known issue for them, cause they mentioned on the TODO as "Fix iOS audio shared instance singleton conflict with internal webrtc." We should wait until they handle it TT

kjhyun824 avatar Jan 26 '21 02:01 kjhyun824

@jsellam we have exactly this problem as well, anyone has an update on solutions/workarounds?

josefha avatar Apr 21 '21 12:04 josefha

I have the same issue. When I start a second call after close the first, I don't have sound...

hi, could you solve it?

kkureli avatar Jun 28 '21 06:06 kkureli

@zxcpoiu any help on this? I'm also facing the same issue. And due to the same reason I can not call stop method at the moment.

sagark1510 avatar Aug 24 '21 12:08 sagark1510

I solved it by manually managing RTCAudioSession. You can see a solution here: https://stackoverflow.com/a/55781328

kiprijonas avatar Oct 20 '21 11:10 kiprijonas

Hi @kiprijonas , if you can give us more information on how to apply this solution please, thank you!

flhember avatar Nov 15 '21 11:11 flhember

Same problem. In my case, it does not work in any call. The microphone and video do, but the audio does not. In Android, it works perfectly. Some news? @saghul

moigamijunior avatar Feb 03 '22 18:02 moigamijunior

I solved it by manually managing RTCAudioSession. You can see a solution here: https://stackoverflow.com/a/55781328

Hi @kiprijonas, I saw your comment, and also your solution, but I cannot seem to link both the situations together. Can you share some snippet please? which files you changed for example?

Thanks in advance!

ssimoe50 avatar Mar 28 '23 07:03 ssimoe50