New issue
Advanced search Search tips

Issue 773613 link

Starred by 3 users

Issue metadata

Status: Duplicate
Merged: issue 774164
Owner:
Closed: Oct 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

webrtc: MediaStream.onaddtrack is not called during renegotiation (behind experimental web platform features flag)

Reported by fi...@appear.in, Oct 11 2017

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/61.0.3163.100 Chrome/61.0.3163.100 Safari/537.36

Steps to reproduce the problem:
1. enable experimental web platform features on chrome://flags
2. go to https://jsfiddle.net/p1kueu86/

What is the expected behavior?
pc.ontrack is called twice. Its only called once

What went wrong?
adapter.js is relying on MediaStream.onaddtrack to shim RTCPeerConnection.ontrack. Most likely this isn't called during renegotiation.

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 63.0.3230.0  Channel: canary
OS Version: 
Flash Version: Shockwave Flash 16.0 r0

From https://github.com/webrtc/adapter/pull/689 -- no workarounds or expected test failures without a bug filed :-)

hbos@ has already taken a quick look
 

Comment 1 by ajha@chromium.org, Oct 11 2017

Cc: ajha@chromium.org
Labels: Needs-Triage-M63 M-63 OS-Mac OS-Windows
Owner: hbos@chromium.org
Status: Assigned (was: Unconfirmed)
Assigning to hbos@ based on C#0.

Comment 2 by hbos@chromium.org, Oct 11 2017

Status: WontFix (was: Assigned)
This is the same as  https://crbug.com/768131#c6 .
It is expected behavior, ontrack should only fire for new tracks, when you renegotiate only the video track is new. You already know about the audio track. You'll be able to know about it ending by listening to the onmute ( https://crbug.com/773523 ).

Comment 3 Deleted

Comment 4 by hbos@chromium.org, Oct 11 2017

Status: Unconfirmed (was: WontFix)
The above comment was with regards to RTCPeerConnection.ontrack, but MediaStream.onaddtrack should fire with the new track. Need to confirm this is a chromium bug and not an adapter bug. The linked fiddle (https://jsfiddle.net/p1kueu86/) only looks at pc.ontrack

Comment 5 by fi...@appear.in, Oct 11 2017

the bug title and my initial analysis were wrong. Title should be "pc.ontrack is not called during renegotiation".

https://jsfiddle.net/p1kueu86/2/ shows that MST.onaddtrack is called (phew!)
adapter.js does not try to shim ontrack when its available natively.

So https://jsfiddle.net/p1kueu86/3/ shows that the native ontrack is not called without adapter either.

Comment 6 by hbos@chromium.org, Oct 11 2017

Status: WontFix (was: Unconfirmed)
When the audio track is added, pc.ontrack fires for the audio track.

During renegotiation the audio track already exists and the video track is added, pc.ontrack fires for the video track (but not for the audio track). Additionally, the stream's onaddtrack fires for the video track that was added to the existing stream.

It works with and without adapter.js. This is the intended behavior.

Comment 7 by hbos@chromium.org, Oct 11 2017

Labels: -M-63 -Needs-Triage-M63 M-64
Status: Fixed (was: WontFix)
Actually this is a real bug, and it is being Fixed with https://chromium-review.googlesource.com/c/chromium/src/+/657639.

At #6 I was trying to repro with a version that already had that patch, that's why I couldn't repro.

Before that patch pc.ontrack only fired for new streams, now they fire for any new tracks. This is related to  https://crbug.com/768131  but that bug is WontFix because it isn't a new stream, this is a real bug / Fixed because it is a new track.

Because that CL is big and risky, I will land it after the cut (making this M-64). Because this is an old bug and not a regression, this should be OK.

Comment 8 by hbos@chromium.org, Oct 11 2017

Status: Started (was: Fixed)
Actually let's make this Started and not Fixed until I land that change.

Comment 9 by fi...@appear.in, Oct 11 2017

that is how I like my bugs... <&
Project Member

Comment 10 by bugdroid1@chromium.org, Oct 13 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/101ae86567ba231c612af756e2bb5925a127ea30

commit 101ae86567ba231c612af756e2bb5925a127ea30
Author: Henrik Boström <hbos@chromium.org>
Date: Fri Oct 13 20:38:59 2017

PC.setRemoteDescription: Use track-based callbacks over stream-based.

In RTP Media API, the processing of remote MediaStreamTracks works with
the "addition" or "removal" of a remote track, i.e. of a receiver. The
receiver has a track and an associated set of streams.
https://w3c.github.io/webrtc-pc/#processing-remote-mediastreamtracks

I refer to the new set of APIs as the track-based APIs, because they're
centered around tracks, tracks being added to streams is a side-effect
to the processing of tracks.

This is different from the stream-based APIs, centered around remote
streams being added or removed. While tracks could be added or removed
from streams in this API there was always the assumption that a stream
owned its track. As such, when a stream was added or removed, all of
its tracks would be created or destroyed.

Switching over to track-based callbacks, the ownership of tracks
changes. A track can be added or removed to zero, one or multiple
streams. On DidAddRemoteTrack we check if a stream or track exist before
we create it and add the track to the stream.

In this CL:
- The receiver's set of associated streams is exposed (C++ layers).
- Stream added/removed callbacks replaced by track added/removed,
  creating or getting streams/tracks based on the receivers.
- Updating mocks and unittests.

All usage cases that worked with addStream/removeStream() should
continue to work with the new callbacks, and the new callbacks will
enable new RTP Media API behavior not previously supported.

Additionally, this fixes  https://crbug.com/773613  because it makes ontrack fire
for new tracks, even if the new tracks are surfaced as belonging to an existing
stream.

Follow-up CLs:
- Add unittests for moving existing tracks between streams and make
  sure we don't end up with multiple tracks.  https://crbug.com/769743 
- With receivers added/removed based on callbacks, define
  getReceivers() as "return rtp_receivers_".  http://crbug.com/755166 

Future CLs:
- All associated events are fired according to spec and in the right
  order.  https://crbug.com/760107 
- Define getRemoteStreams() in terms of "all streams of all receivers".
   https://crbug.com/741618 
- Define addStream/removeStream() in terms of addTrack()/removeTrack().
   https://crbug.com/738929 
- Add usage metrics for add/remove tracks.  https://crbug.com/765170 

Resolving all these bugs will reduce the technical dept.

Bug:  773613 ,  741619 ,  705901 ,  769743 ,  760107 ,  741618 ,  738929 ,  765170 ,  webrtc:7933 
Change-Id: I75c18b889e1d4d5827c53bf6dd627f495ca22b51
Reviewed-on: https://chromium-review.googlesource.com/657639
Commit-Queue: Henrik Boström <hbos@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Guido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#508805}
[modify] https://crrev.com/101ae86567ba231c612af756e2bb5925a127ea30/content/renderer/media/mock_peer_connection_impl.cc
[modify] https://crrev.com/101ae86567ba231c612af756e2bb5925a127ea30/content/renderer/media/mock_peer_connection_impl.h
[modify] https://crrev.com/101ae86567ba231c612af756e2bb5925a127ea30/content/renderer/media/mock_web_rtc_peer_connection_handler_client.cc
[modify] https://crrev.com/101ae86567ba231c612af756e2bb5925a127ea30/content/renderer/media/mock_web_rtc_peer_connection_handler_client.h
[modify] https://crrev.com/101ae86567ba231c612af756e2bb5925a127ea30/content/renderer/media/rtc_peer_connection_handler.cc
[modify] https://crrev.com/101ae86567ba231c612af756e2bb5925a127ea30/content/renderer/media/rtc_peer_connection_handler.h
[modify] https://crrev.com/101ae86567ba231c612af756e2bb5925a127ea30/content/renderer/media/rtc_peer_connection_handler_unittest.cc
[modify] https://crrev.com/101ae86567ba231c612af756e2bb5925a127ea30/content/renderer/media/webrtc/rtc_rtp_receiver.cc
[modify] https://crrev.com/101ae86567ba231c612af756e2bb5925a127ea30/content/renderer/media/webrtc/rtc_rtp_receiver.h
[modify] https://crrev.com/101ae86567ba231c612af756e2bb5925a127ea30/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp
[modify] https://crrev.com/101ae86567ba231c612af756e2bb5925a127ea30/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.h
[modify] https://crrev.com/101ae86567ba231c612af756e2bb5925a127ea30/third_party/WebKit/Source/modules/peerconnection/RTCRtpReceiver.cpp
[modify] https://crrev.com/101ae86567ba231c612af756e2bb5925a127ea30/third_party/WebKit/Source/modules/peerconnection/RTCRtpReceiver.h
[modify] https://crrev.com/101ae86567ba231c612af756e2bb5925a127ea30/third_party/WebKit/public/platform/WebRTCPeerConnectionHandlerClient.h
[modify] https://crrev.com/101ae86567ba231c612af756e2bb5925a127ea30/third_party/WebKit/public/platform/WebRTCRtpReceiver.h

Comment 11 by hbos@chromium.org, Oct 16 2017

Mergedinto: 774164
Status: Duplicate (was: Started)
Merging into 774164 which was filed with a title properly describing the issue.

Sign in to add a comment