You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not covered in "Perfect negotiation in WebRTC", is dealing with an SFU. Fippo explained to me that SFUs can be “pushy”: They’ll send an offer, followed immediately by a second “better” offer. One strategy is the “FIFO peer”:
io.onmessage=async({data: {description, candidate}})=>{if(description){// FIFO peer:awaitPromise.all([// ←- Avoids race!pc.setRemoteDescription(description),// ←- Always an “offer”. Fixed rolespc.createAnswer(),// ←- pc.setLocalDescription({type: "answer"})// ←- Unusual, but works today]);// ←- io.send({description: pc.localDescription});
A second offer may come in while we’re busy responding to the first offer. As a workaround we use Promise.all to front-load the peer connection’s queue with all our methods to get back to "stable" before any other methods get a go!
Even with #2165 fixed, we’re not able to fully get rid of Promise.all here. We’ll still need:
io.onmessage=async({data: {description, candidate}})=>{if(description){awaitPromise.all([// ←- Still neededpc.setRemoteDescription(description),pc.setLocalDescription()]);io.send({description: pc.localDescription});
The SFU FIFO case shows SLD() & SRD() are racy and a bit outdated: from an earlier time when SDP mangling between createOffer/Answer to SLD was allowed (it is now forbidden), and when rejecting m-lines in the answer was common. I propose we give people a simpler and safer alternative that’s race-free and glare-proof:
io.onmessage=async({data: {description, candidate}})=>{if(description){// FIFO peer:awaitpc.setRemoteAndLocalDescriptions(description);// ←- Always an “offer”.io.send({description: pc.localDescription});// because of fixed roles}elseif(candidate){awaitpc.addIceCandidate(candidate);};
Proposal:pc.setRemoteAndLocalDescriptions(description) works like regular SRD, plus, if description is an offer, generates and sets a local answer before resolving. This would be behavior-neutral with the Promise.all case. I.e. if SRD succeeds, but SLD fails, we won’t roll back on failure.
The text was updated successfully, but these errors were encountered:
Not covered in "Perfect negotiation in WebRTC", is dealing with an SFU. Fippo explained to me that SFUs can be “pushy”: They’ll send an offer, followed immediately by a second “better” offer. One strategy is the “FIFO peer”:
A second offer may come in while we’re busy responding to the first offer. As a workaround we use
Promise.all
to front-load the peer connection’s queue with all our methods to get back to "stable" before any other methods get a go!Even with #2165 fixed, we’re not able to fully get rid of
Promise.all
here. We’ll still need:The SFU FIFO case shows SLD() & SRD() are racy and a bit outdated: from an earlier time when SDP mangling between createOffer/Answer to SLD was allowed (it is now forbidden), and when rejecting m-lines in the answer was common. I propose we give people a simpler and safer alternative that’s race-free and glare-proof:
Proposal:
pc.setRemoteAndLocalDescriptions(description)
works like regular SRD, plus, if description is an offer, generates and sets a local answer before resolving. This would be behavior-neutral with thePromise.all
case. I.e. if SRD succeeds, but SLD fails, we won’t roll back on failure.The text was updated successfully, but these errors were encountered: