Bug 176281

Summary: track.onmute isn't called for a remote MediaStreamTrack when its counter part track is removed from the peer connection
Product: WebKit Reporter: Ben <ben.browitt>
Component: WebRTCAssignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, cwehrung, eric.carlson, jer.noble, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Test
none
Patch none

Ben
Reported 2017-09-02 13:10:23 PDT
Created attachment 319733 [details] Test There is no way to detect when a remote peer removes a track in a WebRTC call. I've tried track.onended, track.onmute, stream.onremovetrack: pc.ontrack = function(e) { var track = e.track; var stream = e.streams[0]; // try to detect when a remote track is removed track.onended = function() {console.log('onended')}; track.onmute = function() {console.log('onmute')}; stream.onremovetrack = function() {console.log('onremovetrack')}; } In the attached track.html example you should see "video ended" and "audio ended" in Chrome and Firefox but not in Safari 11.1 Release 38.
Attachments
Test (1.81 KB, text/html)
2017-09-02 13:10 PDT, Ben
no flags
Patch (9.71 KB, patch)
2018-09-17 11:30 PDT, youenn fablet
no flags
Clement Wehrung
Comment 1 2018-09-17 05:14:13 PDT
Hitting the same issue. There doesn't seem to be any good workaround. Ideas?
Radar WebKit Bug Importer
Comment 2 2018-09-17 10:53:14 PDT
youenn fablet
Comment 3 2018-09-17 10:53:43 PDT
Hi Ben, Clement, thanks for the report and test case. As per spec, the track should be muted so an unmute event should probably happen.
youenn fablet
Comment 4 2018-09-17 11:30:22 PDT
Clement Wehrung
Comment 5 2018-09-17 11:48:03 PDT
Happy to test further tomorrow but I did set onmute to the same callback in doubt and it didn't work. Only testing for remote stream. Thanks for looking into it!
Clement Wehrung
Comment 6 2018-09-17 11:49:47 PDT
The proposed workaround from the webrtc-discuss thread works but it's less than ideal: check setRemoteDescription and cache previous media IDs to compare later if one has disappeared
youenn fablet
Comment 7 2018-09-17 12:19:13 PDT
(In reply to Clement Wehrung from comment #5) > Happy to test further tomorrow but I did set onmute to the same callback in > doubt and it didn't work. Only testing for remote stream. Thanks for looking > into it! Right, WebKit is not currently doing so and the posted patch should fix it.
Eric Carlson
Comment 8 2018-09-17 13:49:41 PDT
Comment on attachment 349915 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=349915&action=review > Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:489 > + auto* backend = static_cast<LibWebRTCRtpSenderBackend*>(transceiver->sender().backend()); Nit: downcast<LibWebRTCRtpSenderBackend> would be better, although it is probably a big enough change that you may want to do it in a separate patch.
youenn fablet
Comment 9 2018-09-17 14:55:59 PDT
(In reply to Eric Carlson from comment #8) > Comment on attachment 349915 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=349915&action=review > > > Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:489 > > + auto* backend = static_cast<LibWebRTCRtpSenderBackend*>(transceiver->sender().backend()); > > Nit: downcast<LibWebRTCRtpSenderBackend> would be better, although it is > probably a big enough change that you may want to do it in a separate patch. Right, let's do that in a follow-up patch
WebKit Commit Bot
Comment 10 2018-09-17 15:22:24 PDT
Comment on attachment 349915 [details] Patch Clearing flags on attachment: 349915 Committed r236090: <https://trac.webkit.org/changeset/236090>
WebKit Commit Bot
Comment 11 2018-09-17 15:22:26 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.