MediaStreamTrack on <audio> srcObject continues playing after remove()
Reported by
mrobe...@twilio.com,
Jul 28 2017
|
||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36 Steps to reproduce the problem: If you 1. Receive a MediaStreamTrack from an RTCPeerConnection, 2. Set that MediaStreamTrack in a MediaStream as the srcObject of an <audio> element, 3. Attach that <audio> element to the DOM, 4. Remove the MediaStreamTrack from the <audio> element's srcObject using removeTrack, and 5. Finally remove the <audio> element from the DOM it will continue playing. This does not appear to be the case for other types of MediaStreamTracks. For example, using the Web Audio APIs, I could not reproduce this issue. * WebRTC-based MediaStreamTrack test (fails): https://jsfiddle.net/67mb2vyt/19/ * Web Audio-based MediaStreamTrack test (succeeds): https://jsfiddle.net/e4k58w7p/5/ In both these tests, the <audio> element will be attached, you should hear audio, and then 5 seconds later the <audio> element will be detached. What is the expected behavior? Audio stops playing once detached. What went wrong? Audio continues playing once detached. Did this work before? Yes Does this work in other browsers? No This appears to be a bug in both Chrome and Safari 11 Tech Preview. You can run the WebRTC-based MediaStreamTrack test in both Chrome and Safari 11 Tech Preview; however, the Web Audio-based MediaStreamTrack test only works in Chrome right now. The issue does not occur in Firefox. Chrome version: 59.0.3071.115 Channel: n/a OS Version: OS X 10.12.5 Flash Version: I don't know when last this worked, but I am pretty sure it used to work. (That, or I was using createObjectURL...)
,
Jul 28 2017
After some more testing, I think simply calling `removeTrack` on the <audio> element's `srcObject` should be sufficient to stop the audio from playing in these tests. At least that is how it works in Firefox. Actually removing the <audio> element from the DOM shouldn't matter. In Chrome, I can get the track removal to "take effect", thereby stopping audio playback, if I just set the <audio> element's `srcObject` again, to the same MediaStream, after having called `removeTrack`. It's as if the <audio> element's `srcObject` setter is taking a "snapshot" of the MediaStream's MediaStreamTracks.
,
Jul 28 2017
Related: setting `srcObject` to an empty MediaStream, and then adding an audio MediaStreamTrack to that MediaStream will not playback in Chrome unless you set the `srcObject` attribute on the <audio> element again. https://jsfiddle.net/674vhpvq/2/
,
Jul 28 2017
I think my observations about `srcObject` in Comments 1–3 may duplicate what was reported in https://bugs.chromium.org/p/chromium/issues/detail?id=720258, but my original report about audio playback continuing after removing the <audio> element from the DOM may be a distinct issue.
,
Jul 31 2017
,
Jul 31 2017
The work on issue 720258 should address this, but it has not landed yet.
,
Aug 3 2017
The changes for bug 720258 worked for the script in comment #3. However, the script in the summary still fails. Will take a look at that.
,
Aug 3 2017
It might be a different issue from bug 720258 , as you suggest in #4.
,
Sep 8 2017
Marking as regular bug since this does not seem to have regressed from a previous Chrome version.
,
Mar 3 2018
|
||||
►
Sign in to add a comment |
||||
Comment 1 by mrobe...@twilio.com
, Jul 28 2017