[Solved] Detect whether local browser supports ICE trickle


All modern WebRTC end-points must support Trickle ICE.

JSEP section 5.2.1 says:

An “a=ice-options” line with the “trickle” option MUST be added, as specified in [I-D.ietf-ice-trickle], Section 4.

Additionally, from my reading of the WebRTC spec, for a browser to be conformant, it must implement addIceCandidate etc.

All browsers that support WebRTC today support trickling. The following returns true in Firefox (Chrome appears not to signal this correctly, but rest assured it supports trickling):

new RTCPeerConnection().createOffer({offerToReceiveAudio: true})
.then(offer => console.log(offer.sdp.includes('\r\na=ice-options:trickle')))
.catch(e => log(e));

Interestingly, there’s a pc.canTrickleIceCandidates attribute you can use to detect if the remote peer supports trickling, presumably to support connecting to legacy systems. The following produces true in Firefox (undefined in Chrome, which needs to catch up to the spec):

var pc1 = new RTCPeerConnection(), pc2 = new RTCPeerConnection();

pc1.onicecandidate = e => pc2.addIceCandidate(e.candidate);
pc2.onicecandidate = e => pc1.addIceCandidate(e.candidate);

pc1.onnegotiationneeded = e =>
  pc1.createOffer().then(d => pc1.setLocalDescription(d))
  .then(() => pc2.setRemoteDescription(pc1.localDescription))
  .then(() => pc2.createAnswer()).then(d => pc2.setLocalDescription(d))
  .then(() => pc1.setRemoteDescription(pc2.localDescription))
  .then(() => console.log(pc1.canTrickleIceCandidates))
  .catch(e => console.log(e));

pc1.createDataChannel("dummy");

0

solved Detect whether local browser supports ICE trickle