Skip to content

Conversation

@youennf
Copy link
Contributor

@youennf youennf commented Nov 5, 2025

No description provided.

@henbos
Copy link
Contributor

henbos commented Nov 5, 2025

Stream IDs are communicated in SDP and are always accurate.

Track IDs are... a bit of a mess. When you addTransceiver or addTrack it creates the RTCRtpReceiver including its MediaStreamTrack, prior to negotiating, so your remote track ID might not match what the track is on the other side, or you can replaceTrack later or the first time you negotiate maybe sender track is null etc etc.

The track ID being present in SDP is just for backwards compatibility, it's not something you can rely on

@henbos
Copy link
Contributor

henbos commented Nov 5, 2025

IIRC if the receiver was created in response to SDP from the other side and that other side happened to have the track set by the time the m-section was formed for the first time, then the track identifier will probably match, otherwise it will probably not match

@henbos
Copy link
Contributor

henbos commented Nov 5, 2025

It would be less foot-gunny if we never had the track ID match just to avoid people depending on this, but I don't want to change anything that is already de facto standard... ramble ramble. WPTs are good.

@alvestrand
Copy link
Contributor

The WEBRTC spec claims that the track IDs are uncorrelated - this was a result of the discussion around the decision to incorporate ReplaceTrack as a function not requiring a new offer/answer. (The stream IDs are carried over).

The msid spec RFC claims (I think) that the track ID will be set from the MSID attribute - this was locked down as an RFC before we decided to change the way track IDs behaved in the WEBRTC spec, I believe.

function testTrackId(localTrack, remoteTrack, kind)
{
test(() => {
assert_not_equals(localTrack.id, remoteTrack.id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://w3c.github.io/webrtc-pc/#rtcrtpreceiver-interface says

Let track be a new MediaStreamTrack object [GETUSERMEDIA]. The source of track is a remote source provided by receiver. Note that the track.id is generated by the user agent and does not map to any track IDs on the remote side.

If the IDs are random, the test will occasionally fail; if the IDs are obeying the older rule, they will collide.
Not sure if the test is appropriate or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the IDs are obeying the older rule, they will collide.

That is what we want to test.
I can remove it from now, or update the test to create 10 connections with the same track ID on the local track and verify that at lease one of the remote track has a different ID.

If the IDs are random, the test will occasionally fail

Most likely, UUIDs will be used, at which point the collisions are very unlikely.
Maybe the spec should say so.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test updated.

@youennf youennf force-pushed the check-remote-track-properties branch from baaff96 to 026978c Compare November 6, 2025 07:43
@youennf youennf requested a review from alvestrand November 6, 2025 07:44
@youennf
Copy link
Contributor Author

youennf commented Nov 6, 2025

FWIW, the compat issue we identified was related to remote track labels.

We haven't identified a compat issue related to the the track ids, but it seems best to converge there as well.
Only Firefox is implementing IDs correctly at the moment.

@youennf
Copy link
Contributor Author

youennf commented Nov 6, 2025

As per my reading of the spec, MediaStreamTrack.id isinitialized to a newly generated unique identifier string.
So the past version of the test was correct. I'll file a spec issue to see whether we should clarify this in webrtc-pc.

@youennf
Copy link
Contributor Author

youennf commented Nov 6, 2025

I filed w3c/webrtc-pc#3084

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants