简体   繁体   中英

ICE candidates not generating on Android 11 Chrome in some devices

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.

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!

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)
                });

            });
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM