According to the spec, adding and then removing a track from a RTCPeerConnection can be done as follows: let pc = new RTCPeerConnection(); let sender = pc.addTrack(track, stream); // Negotiate,... sender.replaceTrack(null); This works fine on Chrome and Firefox. On Safari however, the call to replaceTrack() stops the track entirely, setting readyState to "ended" (but interestingly, not calling the onended callback). This makes it impossible to use this method to remove a track that is still used elsewhere. This is problematic, especially since pc.removeTrack(track) is buggy as well: https://bugs.webkit.org/show_bug.cgi?id=174327 This example should demonstrate the issue: https://jsfiddle.net/vt55wx9u/4/.
<rdar://problem/40758138>
Created attachment 342919 [details] Patch
Comment on attachment 342919 [details] Patch Attachment 342919 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/8229141 New failing tests: imported/w3c/web-platform-tests/webrtc/RTCRtpSender-replaceTrack.html
Created attachment 342920 [details] Archive of layout-test-results from ews106 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews106 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
Comment on attachment 342919 [details] Patch Attachment 342919 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/8229193 New failing tests: imported/w3c/web-platform-tests/webrtc/RTCRtpSender-replaceTrack.html
Created attachment 342923 [details] Archive of layout-test-results from ews124 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews124 Port: ios-simulator-wk2 Platform: Mac OS X 10.13.4
Created attachment 342927 [details] Patch
Comment on attachment 342927 [details] Patch Attachment 342927 [details] did not pass gtk-wk2-ews (gtk-wk2): Output: http://webkit-queues.webkit.org/results/8238825 New failing tests: http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html
Created attachment 342999 [details] Archive of layout-test-results from ltilve-gtk-wk2-ews for gtk-wk2 The attached test failures were seen while running run-webkit-tests on the gtk-wk2-ews. Bot: ltilve-gtk-wk2-ews Port: gtk-wk2 Platform: Linux-4.16.0-0.bpo.1-amd64-x86_64-with-debian-9.4
Comment on attachment 342927 [details] Patch gtk error is unrelated
Comment on attachment 342927 [details] Patch Clearing flags on attachment: 342927 Committed r232956: <https://trac.webkit.org/changeset/232956>
All reviewed patches have been landed. Closing bug.