New issue
Advanced search Search tips

Issue 921452 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Jan 14
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Tracks not added to the SDP when generating an answer (Unified Plan)

Reported by xsvengo...@gmail.com, Jan 14

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0

Steps to reproduce the problem:
1. Open the example page
2. Select the Unified Plan
3. Click Start
4. Click Call
5. Click Add Video

What is the expected behavior?
The RTCPeerConnection.ontrack event is thrown for Client B and the video stream is displayed in a new video element. Three videos in total are displayed on the screen.

What went wrong?
The RTCPeerConnection.ontrack event is never thrown and the SDP doesn't appear to contain any details on the newly added track.

Did this work before? N/A 

Does this work in other browsers? N/A

Chrome version: 72.0.3626.53 (Official Build) beta (64-bit) (cohort: Beta)  Channel: n/a
OS Version: 10.0
Flash Version: Shockwave Flash 29.0 r0

More specifically, Client A will only generate answers and Client B will only generate offers. I modified the sample found here: https://webrtc.github.io/samples/src/content/peerconnection/pc1/

This functionality has been working with the old 'Plan B' and I noticed this issue when testing with the new 'Unified Plan'.

Here are the detailed steps on whats happening in the page:
1. Create a peerconnection for both clients and have Client A add a track.
2. Negotiate the connection by having Client B create an offer and Client A create an answer.
3. Have Client A add another video track to the peerconnection
4. Renegotiate by having Client B create an offer and Client A create an answer
 
pc1.zip
5.1 KB Download
bug-example.webm
6.1 MB View Download
Components: -Blink>WebRTC Blink>WebRTC>PeerConnection
Owner: hbos@chromium.org
Status: Assigned (was: Unconfirmed)
hbos@, can you take a look?
Your code does not work in Unified Plan because it is using offerToReceive incorrectly.
Code snippet:

async function addVideo() {
  // Request a new stream and add it to pc1
  // then have pc2 generate an offer
  try {
	const stream = await navigator.mediaDevices.getUserMedia({audio: true, video: true});
	console.log('Received local stream');
	
	stream.getTracks().forEach(track => pc1.addTrack(track, stream));
    console.log('Added local stream to pc1');

    try {
      console.log('pc2 createOffer start');
      const offer = await pc2.createOffer(offerOptions);
      await onCreateOfferSuccess(offer);
    } catch (e) {
      onCreateSessionDescriptionError(e);
    }
	
  } catch (e) {
	alert(`getUserMedia() error: ${e.name}`);
  }
}

In Unified Plan, each track has its own transceiver which has its own m= section. So if you're adding a new track to pc1 either pc1 has to be the one creating the offer telling pc2 to create another transceiver to receive the track - here it is pc2 that is creating the offer - or pc2 has to have spare transceivers that it can reuse to receive pc1's newly added track. The side creating an answer is NOT ALLOWED to add new m= sections.

So, why does this work in Plan B? It works because offerToReceive options creates the m=audio and m=video sections, and because in Plan B you don't need multiple m= sections for multiple tracks of the same kind. A Plan B client that is ready to receive is ready to receive any number of tracks.

In Unified Plan, offerToReceive is a legacy configuration extension http://w3c.github.io/webrtc-pc/#legacy-configuration-extensions. The language is a bit hard to parse, but basically it adds a "recvonly"-transceiver for you if you don't already have a "sendrecv" or "recvonly" transceiver. Because you already have one (due to the initial call), createOffer() does not offer to receive anything other than what it is already receiving, and pc2 does not get offered anything that it can send its track to.

Try this before you create the offer:
  pc2.addTransceiver('audio');
  pc2.addTransceiver('video');
Or make pc1 the offerer.
Status: WontFix (was: Assigned)
Note that there is a bug that means you can't tell from JavaScript if a transceiver was created by createOffer() or not until further negotiation steps - https://crbug.com/911090 - but that does not affect whether or not this demo page works.

So in terms of not being able to do what "addVideo()" is trying to do above, that is working as intended and this is not a Chrome bug. If we would like offerToReceive to be more useful that would be a spec issue (https://github.com/w3c/webrtc-pc/issues) but I suggest not relying on legacy configuration extensions.

I'm marking this as WontFix (= works as intended), but feel free to correct me if #2 is wrong if this should be reopened.
Typo: It's supposed to say "pc1 does not get offered anything that it can send its tracks to" above not pc2.
Thanks for taking the time to write that out. I have a better understanding on whats going on now. The website I need to update for the Unified Plan solves signal glare by giving one of the two clients the role of generating offers for negotiation. It's always the same client that generates the offer. It sounds like one way to fix my problem is to re-work the signal glare code so that each client has the chance to create an offer when tracks are added/removed from their peerconnection, without re-introducing the glare problem...somehow. I'll have to figure that one out.

You would know better than me if this is a spec issue. Thanks again!

Sign in to add a comment