Bug 180342 - replaceTrack triggers negotiationneeded
Summary: replaceTrack triggers negotiationneeded
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-12-03 19:48 PST by Andrew Morris
Modified: 2018-03-15 15:36 PDT (History)
4 users (show)

See Also:


Attachments
Patch (4.10 KB, patch)
2018-03-15 14:03 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Morris 2017-12-03 19:48:25 PST
1. Go to basic peer connection demo from webrtc samples: https://webrtc.github.io/samples/src/content/peerconnection/pc1/
2. Run this in the console:
(async () => {
  pc1.addEventListener('negotiationneeded', evt => console.log('pc1 negotiationneeded', evt));
  await new Promise(resolve => setTimeout(resolve, 250));
  const initialVideoTrack = pc1.getSenders()[1].track;
  await pc1.getSenders()[1].replaceTrack(initialVideoTrack);
  console.log('done');
})().catch(err => console.error(err));


Result: 'pc1 negotiationneeded [...]' is logged
Expected: 'pc1 negotiationneeded [...]' is not logged (and no visible changes really)

I could be wrong about this being a bug, but Firefox does not do this, and in my understanding the whole point of replaceTrack is that you can just start pulling frames from a new source and nothing much needs to happen.

Safari 11 stable is also affected. Tested on (non-high) Sierra.
Comment 1 Andrew Morris 2017-12-03 20:05:26 PST
I'm not sure why I can't reproduce this on the webrtc samples page but when I do the same kind of thing with the OpenTok SDK it generates a new offer in response to this new event and [[todo: add description]].

Initial offer:
-------------------
v=0
o=- 7609724054059362131 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE audio video
a=msid-semantic: WMS a40b4846-897a-4e39-bbda-58353279328c
m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 102 0 8 106 105 13 110 112 113 126
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:MafM
a=ice-pwd:Ae6ygV1areELvRZVSKe+s9MM
a=ice-options:trickle
a=fingerprint:sha-256 90:62:6B:7A:D7:B0:F6:14:5C:E0:39:87:49:6A:ED:DE:6E:53:16:D1:F1:0A:61:27:9F:0A:EA:44:63:BF:14:C0
a=setup:actpass
a=mid:audio
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=sendrecv
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap:104 ISAC/32000
a=rtpmap:9 G722/8000
a=rtpmap:102 ILBC/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:112 telephone-event/32000
a=rtpmap:113 telephone-event/16000
a=rtpmap:126 telephone-event/8000
a=ssrc:1371791958 cname:a2HB65MoahQnEdTo
a=ssrc:1371791958 msid:a40b4846-897a-4e39-bbda-58353279328c 220d2952-77dd-4b90-ba4b-55587f8734de
a=ssrc:1371791958 mslabel:a40b4846-897a-4e39-bbda-58353279328c
a=ssrc:1371791958 label:220d2952-77dd-4b90-ba4b-55587f8734de
m=video 9 UDP/TLS/RTP/SAVPF 96 98 99 97 100
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:MafM
a=ice-pwd:Ae6ygV1areELvRZVSKe+s9MM
a=ice-options:trickle
a=fingerprint:sha-256 90:62:6B:7A:D7:B0:F6:14:5C:E0:39:87:49:6A:ED:DE:6E:53:16:D1:F1:0A:61:27:9F:0A:EA:44:63:BF:14:C0
a=setup:actpass
a=mid:video
a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:4 urn:3gpp:video-orientation
a=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=sendrecv
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 red/90000
a=rtpmap:98 ulpfec/90000
a=rtpmap:99 H264/90000
a=rtcp-fb:99 ccm fir
a=rtcp-fb:99 nack
a=rtcp-fb:99 nack pli
a=rtcp-fb:99 goog-remb
a=rtcp-fb:99 transport-cc
a=fmtp:99 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
a=rtpmap:97 rtx/90000
a=fmtp:97 apt=96
a=rtpmap:100 rtx/90000
a=fmtp:100 apt=99
a=ssrc-group:FID 1703086589 1076479466
a=ssrc:1703086589 cname:a2HB65MoahQnEdTo
a=ssrc:1703086589 msid:a40b4846-897a-4e39-bbda-58353279328c d96e5f40-9467-4c26-b2d1-3152f459286d
a=ssrc:1703086589 mslabel:a40b4846-897a-4e39-bbda-58353279328c
a=ssrc:1703086589 label:d96e5f40-9467-4c26-b2d1-3152f459286d
a=ssrc:1076479466 cname:a2HB65MoahQnEdTo
a=ssrc:1076479466 msid:a40b4846-897a-4e39-bbda-58353279328c d96e5f40-9467-4c26-b2d1-3152f459286d
a=ssrc:1076479466 mslabel:a40b4846-897a-4e39-bbda-58353279328c
a=ssrc:1076479466 label:d96e5f40-9467-4c26-b2d1-3152f459286d
-------------------

Offer after replaceTrack:
-------------------
v=0
o=- 7609724054059362131 3 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE audio video
a=msid-semantic: WMS a40b4846-897a-4e39-bbda-58353279328c
m=audio 7724 UDP/TLS/RTP/SAVPF 111 103 104 9 102 0 8 106 105 13 110 112 113 126
c=IN IP4 61.88.29.110
a=rtcp:9 IN IP4 0.0.0.0
a=candidate:3368096812 1 udp 2113937151 10.100.5.213 61969 typ host generation 0 network-cost 50
a=candidate:842163049 1 udp 1677729535 61.88.29.110 7724 typ srflx raddr 10.100.5.213 rport 61969 generation 0 network-cost 50
a=ice-ufrag:MafM
a=ice-pwd:Ae6ygV1areELvRZVSKe+s9MM
a=ice-options:trickle
a=fingerprint:sha-256 90:62:6B:7A:D7:B0:F6:14:5C:E0:39:87:49:6A:ED:DE:6E:53:16:D1:F1:0A:61:27:9F:0A:EA:44:63:BF:14:C0
a=setup:actpass
a=mid:audio
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=sendrecv
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap:104 ISAC/32000
a=rtpmap:9 G722/8000
a=rtpmap:102 ILBC/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:112 telephone-event/32000
a=rtpmap:113 telephone-event/16000
a=rtpmap:126 telephone-event/8000
a=ssrc:1371791958 cname:a2HB65MoahQnEdTo
a=ssrc:1371791958 msid:a40b4846-897a-4e39-bbda-58353279328c 220d2952-77dd-4b90-ba4b-55587f8734de
a=ssrc:1371791958 mslabel:a40b4846-897a-4e39-bbda-58353279328c
a=ssrc:1371791958 label:220d2952-77dd-4b90-ba4b-55587f8734de
m=video 12078 UDP/TLS/RTP/SAVPF 96 98 99 97 100
c=IN IP4 61.88.29.110
a=rtcp:9 IN IP4 0.0.0.0
a=candidate:3368096812 1 udp 2113937151 10.100.5.213 59136 typ host generation 0 network-cost 50
a=candidate:842163049 1 udp 1677729535 61.88.29.110 12078 typ srflx raddr 10.100.5.213 rport 59136 generation 0 network-cost 50
a=ice-ufrag:MafM
a=ice-pwd:Ae6ygV1areELvRZVSKe+s9MM
a=ice-options:trickle
a=fingerprint:sha-256 90:62:6B:7A:D7:B0:F6:14:5C:E0:39:87:49:6A:ED:DE:6E:53:16:D1:F1:0A:61:27:9F:0A:EA:44:63:BF:14:C0
a=setup:actpass
a=mid:video
a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:4 urn:3gpp:video-orientation
a=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=sendrecv
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 red/90000
a=rtpmap:98 ulpfec/90000
a=rtpmap:99 H264/90000
a=rtcp-fb:99 ccm fir
a=rtcp-fb:99 nack
a=rtcp-fb:99 nack pli
a=rtcp-fb:99 goog-remb
a=rtcp-fb:99 transport-cc
a=fmtp:99 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
a=rtpmap:97 rtx/90000
a=fmtp:97 apt=96
a=rtpmap:100 rtx/90000
a=fmtp:100 apt=99
a=ssrc-group:FID 1703086589 1076479466
a=ssrc:1703086589 cname:a2HB65MoahQnEdTo
a=ssrc:1703086589 msid:a40b4846-897a-4e39-bbda-58353279328c d96e5f40-9467-4c26-b2d1-3152f459286d
a=ssrc:1703086589 mslabel:a40b4846-897a-4e39-bbda-58353279328c
a=ssrc:1703086589 label:d96e5f40-9467-4c26-b2d1-3152f459286d
a=ssrc:1076479466 cname:a2HB65MoahQnEdTo
a=ssrc:1076479466 msid:a40b4846-897a-4e39-bbda-58353279328c d96e5f40-9467-4c26-b2d1-3152f459286d
a=ssrc:1076479466 mslabel:a40b4846-897a-4e39-bbda-58353279328c
a=ssrc:1076479466 label:d96e5f40-9467-4c26-b2d1-3152f459286d
a=ssrc-group:FID 1982847902 820166425
a=ssrc:1982847902 cname:a2HB65MoahQnEdTo
a=ssrc:1982847902 msid:a40b4846-897a-4e39-bbda-58353279328c f11c251f-1672-4755-ab37-9d764c14d05a
a=ssrc:1982847902 mslabel:a40b4846-897a-4e39-bbda-58353279328c
a=ssrc:1982847902 label:f11c251f-1672-4755-ab37-9d764c14d05a
a=ssrc:820166425 cname:a2HB65MoahQnEdTo
a=ssrc:820166425 msid:a40b4846-897a-4e39-bbda-58353279328c f11c251f-1672-4755-ab37-9d764c14d05a
a=ssrc:820166425 mslabel:a40b4846-897a-4e39-bbda-58353279328c
a=ssrc:820166425 label:f11c251f-1672-4755-ab37-9d764c14d05a
-------------------

The main change here is that a new ssrc-group has been added:

-------------------
a=ssrc-group:FID 1982847902 820166425
a=ssrc:1982847902 cname:a2HB65MoahQnEdTo
a=ssrc:1982847902 msid:a40b4846-897a-4e39-bbda-58353279328c f11c251f-1672-4755-ab37-9d764c14d05a
a=ssrc:1982847902 mslabel:a40b4846-897a-4e39-bbda-58353279328c
a=ssrc:1982847902 label:f11c251f-1672-4755-ab37-9d764c14d05a
a=ssrc:820166425 cname:a2HB65MoahQnEdTo
a=ssrc:820166425 msid:a40b4846-897a-4e39-bbda-58353279328c f11c251f-1672-4755-ab37-9d764c14d05a
a=ssrc:820166425 mslabel:a40b4846-897a-4e39-bbda-58353279328c
a=ssrc:820166425 label:f11c251f-1672-4755-ab37-9d764c14d05a
-------------------

And every time this process is repeated there is another ssrc-group resulting in an ever-growing sdp.

By the way, when I try to reproduce this in the webrtc sample page, createOffer throws this exception:
OperationError (DOM Exception 34): CreateOffer called with invalid media streams.
Comment 2 Andrew Morris 2017-12-03 20:07:35 PST
Ack, I forgot to replace [[todo: add description]] above, I should have replaced it with 'there is a new ssrc-group'.
Comment 3 youenn fablet 2017-12-03 20:08:18 PST
> in my understanding the whole point of replaceTrack is that you can just
> start pulling frames from a new source and nothing much needs to happen.

That is also my understanding, there is probably a bug there.
Comment 4 Radar WebKit Bug Importer 2017-12-03 20:09:00 PST
<rdar://problem/35822426>
Comment 5 youenn fablet 2018-03-15 14:03:44 PDT
Created attachment 335878 [details]
Patch
Comment 6 WebKit Commit Bot 2018-03-15 15:36:47 PDT
Comment on attachment 335878 [details]
Patch

Clearing flags on attachment: 335878

Committed r229644: <https://trac.webkit.org/changeset/229644>
Comment 7 WebKit Commit Bot 2018-03-15 15:36:48 PDT
All reviewed patches have been landed.  Closing bug.