WebRTC Safari: No reception if no emission (more precisely no ICE candidate callback)

The following JS fiddle shows that Safari doesn't want to receive a video stream if a local video track has not been added. More precisely, the ICE candidate callback never happens.


https://jsfiddle.net/2r5mocfz/


  • Using Chrome: Click on "Without Local Camera", you are getting the ICE candidate callback with the alert messages.
  • Using Safari: Click on "Without Local Camera", you are NOT getting the ICE candidate callback. You are getting it only if you click on "With Local Camera" and accept to use your local camera.


The javascript code is:


function handleICECandidateEvent(event) {
    alert("ICE callback");
    console.log(event);
}

async function start_(arg) {
    alert("Starting " + arg);
    let peerConnection = new RTCPeerConnection({iceServers:[{urls: 'stun:stun1.l.google.com:19302'}]});
    peerConnection.onicecandidate = handleICECandidateEvent;
  if (arg) {
        const s = await navigator.mediaDevices.getUserMedia({video:true});
        s.getTracks().forEach(track => {peerConnection.addTrack(track, s);});
  }
    const offer = await peerConnection.createOffer({offerToReceiveAudio: true, offerToReceiveVideo: true});
    await peerConnection.setLocalDescription(offer);
}


Is there any workaround? I would like on Safari to receive a WebRTC video stream without having to involve a local camera with its permission request?

Posted on Mar 5, 2023 07:44 PM

Reply

Similar questions

1 reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

WebRTC Safari: No reception if no emission (more precisely no ICE candidate callback)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.