2

While trying out WebRTC, I found out that it is creating issues in some Android devices having Android 11 (mostly Samsung, Vivo) in Chrome. However, it is working fine in Firefox on the same device. I tested on Samsung Galaxy A03s (SM-A037F).

I tried this - https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/ In Chrome, candidates are not gathered but in Firefox, candidates are gathering.

I found a similar bug in the Chromium bug tracker - https://bugs.chromium.org/p/chromium/issues/detail?id=1115498 Still issue doesn't seem to be fixed.

How can we make it work in the Chrome browser? Please help.

0

2 Answers 2

1

Same problem. If you try to set iceCandidatePoolSize = 10 in the configuration for RTCPeerConnection, then onicecandidate fires once with an empty candidate, iceConnectionState changes to the connected state.

Then I watch transceivers pc.getTransceivers()[0].sender.transport.iceTransport

gatheringState: "complete" state: "connected"

pc.getTransceivers()[0].sender.transport.iceTransport.getSelectedCandidatePair() Success! There is a selected pair!

But pc.connectionState still has a connecting state and hangs in it endlessly...

Tried on wifi and gsm connections... I don't understand anything!

Checked on other devices in the same network (wifi):

Android 11 - Samsung Galaxy M12 - Success
Android 11 - Samsung Galaxy TAB A (2019) - Success
Android 11 - Samsung Galaxy A22 (my) - FAIL

Workarround for me:

let pc = new RTCPeerConnection({iceCandidatePoolSize: 1}) //any > 0
pc.oniceconnectionstatechange = function(){

   if(pc.iceConnectionState === "connected") {      
      for (let tr of pc.getTransceivers()) {

          let selected = tr.sender.transport.iceTransport.getSelectedCandidatePair();
          if (selected) {
              //send selected.local to you server...
          }
      }
    }
}

Bug chromium:
https://bugs.chromium.org/p/chromium/issues/detail?id=1240237

0

I think i've got a work around for this. It's only happening on the first webrtc connection - it works on retry, so i added this code to my project and it seems to fix it:

fixAndroid = function (turn) {
            console.log("fixing android webrtc bug");
            var cn = new RTCPeerConnection(turn, null);
            cn.createOffer({
                offerToReceiveAudio: true,
                offerToReceiveVideo: true
            }).then(offer => {
                let rtcDesc = new RTCSessionDescription(offer);
                cn.setLocalDescription(rtcDesc, function () {
                        //needs a second to initialise 
                        window.setTimeout(function (cn) {
                        cn.close(); 
                        // start your webrtc connection here
                    }, 1000, cn)
                });

            });
        }

Not the answer you're looking for? Browse other questions tagged or ask your own question.