Closed Bug 1192170 Opened 9 years ago Closed 9 years ago

GetUserMedia MediaStream.stop() should no longer be used but is still required to get rid of permission indicator after stopping all local tracks

Categories

(Core :: WebRTC: Audio/Video, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla44
Tracking Status
firefox44 --- fixed

People

(Reporter: longsleep, Assigned: pehrsons)

References

()

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.15 Safari/537.36 Steps to reproduce: Capture a local media device with getUserMedia and stop all the tracks. Actual results: The devices get disabled but the media capture permission indicator stays visible. Expected results: MediaStream.stop() is deprecated and instead one should use the stop() function on the tracks. While the camera and mic gets stopped fine when stopping the corresponding tracks, the permission indicator for the audio and/or video capture permissions stays until MediaStream.stop() is called. In the getUserMedia case the stream implementes the LocalMediaStream prototype which still seems to have a stop() function to exactly do this. LocalMediaStream needs to go away and the behavior should be added to MediaStreamTrack.stop() so that the code example below does also remove the permission indicator. navigator.getUserMedia({audio: false, video: true}, function(stream) { // can also use getAudioTracks() or getVideoTracks() var track = stream.getTracks()[0]; // if only one media track // ... track.stop(); }, function(error){ console.log('getUserMedia() error', error); }); This happens with current stable (39) and also with current nightly (42), Workaround is to call the stop() function on the LocalMediaStream in addition to stopping the tracks.
Added a simple fiddle to reproduce - run it here: https://jsfiddle.net/efzss9fc/ var p = navigator.mediaDevices.getUserMedia({audio: false, video: true}); p.then(function(stream) { console.log("stream", stream); var track = stream.getTracks()[0]; console.log("track", track); track.stop(); }); p.catch(function(e) { console.log(e.name); });
Component: Untriaged → Device Permissions
Version: 39 Branch → Trunk
I don't think this is a front-end issue; or at least I think there's something to do in the back-end to get this fixed, as there's likely a missing notification, or mediaCaptureWindowState not returning the right value.
Component: Device Permissions → WebRTC: Audio/Video
Product: Firefox → Core
Status: UNCONFIRMED → NEW
backlog: --- → webrtc/webaudio+
Rank: 18
Ever confirmed: true
Priority: -- → P1
This is because the ending of our internal gUM stream triggers removal of the sharing indicator. The spec doesn't have ending streams anymore, just ending tracks (streams are now active/inactive depending on whether they have any non-ended tracks). Before we get to fixing this in our stack we can just fix the indicator by removing it when all tracks in a given `GetUserMediaCallbackMediaStreamListener` have stopped.
Assignee: nobody → pehrsons
Status: NEW → ASSIGNED
Bug 1192170 - Remove media capture indicator when all tracks have ended. r?jib
Attachment #8665239 - Flags: review?(jib)
Comment on attachment 8665239 [details] MozReview Request: Bug 1192170 - Remove media capture indicator when all tracks have ended. r?jib https://reviewboard.mozilla.org/r/20173/#review18101 lgtm. ::: dom/media/MediaManager.h:183 (Diff revision 1) > + !mVideoDevice->GetSource()->IsAvailable() && > mVideoDevice->GetMediaSource() == dom::MediaSourceEnum::Camera && Do we want to check dom::MediaSourceEnum::Camera first, or do all sources support IsAvailable()?
Attachment #8665239 - Flags: review?(jib) → review+
https://reviewboard.mozilla.org/r/20173/#review18101 > Do we want to check dom::MediaSourceEnum::Camera first, or do all sources support IsAvailable()? All sources do, and we're already checking `IsAvailable()` for the others in `CapturingScreen/Window/Application/Browser`.
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
Some clarification on STRs for this bug. It seems to depend on the order the tracks are closed in. Closing them in reverse order leaves the light on, while closing them in regular forEach order seems to work: http://jsfiddle.net/jib1/eq9z0d0h/
This might be worth uplifting.
(In reply to Jan-Ivar Bruaroey [:jib] from comment #10) > Some clarification on STRs for this bug. It seems to depend on the order the > tracks are closed in. > > Closing them in reverse order leaves the light on, while closing them in > regular forEach order seems to work: http://jsfiddle.net/jib1/eq9z0d0h/ No, that's not it. Here, I fixed your fiddle: http://jsfiddle.net/eq9z0d0h/5/ (audio was false, so tracks[1] was undefined)
(In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #13) > No, that's not it. Here, I fixed your fiddle: http://jsfiddle.net/eq9z0d0h/5/ > > (audio was false, so tracks[1] was undefined) And with that I think I confused myself by looking at the camera LED rather than the in-Firefox indicator. Sorry, you're right jib!
(In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #13) > (audio was false, so tracks[1] was undefined) Ugh, yeah sorry about the confusion. Ah, so the camera light is fine, it was just the Firefox camera indicator that was wrong.

https://nimiq.github.io/qr-scanner/demo/

this isn't working in nightly 71.0a1 (2019-09-25) (64-bit) or 69.0.1 (64-bit) on Win10

the red video indicator stays on if you type in the console

document.getElementById('qr-video').srcObject.getTracks()[0].stop()

(In reply to Zac Spitzer from comment #16)

https://nimiq.github.io/qr-scanner/demo/

this isn't working in nightly 71.0a1 (2019-09-25) (64-bit) or 69.0.1 (64-bit) on Win10

the red video indicator stays on if you type in the console

document.getElementById('qr-video').srcObject.getTracks()[0].stop()

See bug 1568169.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: