Open Bug 1667635 Opened 4 years ago Updated 2 months ago

AbortError Starting video failed returned from getUserMedia until Firefox restarted

Categories

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

Firefox 81
defect

Tracking

()

UNCONFIRMED

People

(Reporter: steven.michaels, Unassigned, NeedInfo)

References

Details

Attachments

(1 file)

Attached file test.html

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36

Steps to reproduce:

  1. In Firefox, open a webpage that calls navigator.mediaDevices.getUserMedia({video: true}) with a video element (see attached HTML for basic example). (audio and video both true will also create same behavior).
  2. Confirm the webpage works, displaying the video.
  3. Navigate away from the webpage.
  4. Open any other application that utilizes the camera. (I used the stock Windows 10 Camera app, but this can also be something like Chrome opening the same example webpage.)
  5. In Firefox, navigate to the webpage from the attachment again.
  6. MediaStreamError - AbortError - Starting video failed - will display in the console, as expected.
  7. Close out the conflicting app that was started in step #4, releasing control of the camera again.
  8. Navigate away from the webpage in Firefox and back to it - the MediaStreamError from #6 will continue to display in perpetuity until the browser is restarted. New tabs/windows, new private window will still contain the error.

May be related to #1663913.

Additional environment data that may be useful:
Windows_NT 10.0 19041
"Integrated Webcam" on a Dell Alienware m15 laptop

Actual results:

MediaStreamError AbortError will always display until browser is restarted.

Expected results:

Error should not occur after the blocking application has closed and relinquished control of the device.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → WebRTC: Audio/Video
Product: Firefox → Core

I'm having a look later today, I don't have my windows machine right now.

Severity: -- → S1
Flags: needinfo?(jib)
Flags: needinfo?(dminor)
Priority: -- → P1

Hi Steven, thanks for filing! Did this used to work in a previous version of Firefox do you know?

Would you mind running mozregression on it? This might help us narrow in on the problem and also help us prioritize this correctly.

Severity: S1 → S2
Flags: needinfo?(jib) → needinfo?(steven.michaels)
See Also: → 1663913

Hi, I don't have time for much work on this for a few weeks, but the workaround of restarting or clearing the cache and navigating back to the problem site seems to be working in the meantime. I did some very quick tests on 75, 70, and 65, and there seems to have been a change between 65 and 70. In 65, if I get the AbortError and refresh the page, just a refresh of the page works, but in 70, the AbortError sticks around even after refresh. I'll submit the mozregression testing sometime in October - I appreciate the patience and work on this.

Flags: needinfo?(steven.michaels)

After an OS update, my old windows laptop now blue screens whenever I try to access the camera in Firefox, so I'm not really in any shape to investigate this right now. Sorry!

Flags: needinfo?(dminor)

Bryce, could you give this a try on your Windows machine to see if you can repro?

Flags: needinfo?(bvandyk)

I can't repro this on my machine in Nightly. When I get to step 8 of comment 0 Firefox reprompts me for camera access and the test page works. I've tested with Chrome and also with Windows' Camera app. If I use the forward button to navigate back to the test page I sometimes get a cached version which doesn't work until I refresh (not error in console though).

Reporter, can you still repro?

Flags: needinfo?(bvandyk) → needinfo?(steven.michaels)

Any updates on the above issue, i seems to be getting the same for navigator.mediaDevices.getUserMedia({ audio: true, video: true }).
I am using windows 10 licensed and firefox 866, after the camera permission is granted we get the following error in console 'AbortError: Starting video failed'. Restart ff etc are not working.

Flags: needinfo?(sunny85indore)

I found that allowing the option 'Allow Apps to access your microphone' seems to do the job for FF in windows 10. But this is strange because similar settings were not required for chrome or edge. Thanks.

Flags: needinfo?(sunny85indore)

I routinely get this error, and after coming back to this "unconfirmed" bug for the n-th time, I have decided to offer a simple test example, which gets me an AbortError exception (from navigator.mediaDevices.getUserMedia promise rejecting) with the message "Starting video failed":

<!DOCTYPE html>
<html>
	<head>
		<script>
			async function test() {
				async function sleep(n) {
					await new Promise(resolve => setTimeout(resolve, n));
				}
				var stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
				await sleep(5000);
				for(const track of stream.getTracks()) track.stop();
				await sleep(5000);
				stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
			}
		</script>
	</head>
	<body>
		<input type="button" onclick="test()" value="Test" />
	</body>
</html>

As you can see from the above, I even stop all tracks in case FF is unable/unwilling to vend another stream when a stream already uses underlying source -- but this has no effect since I still get the error. I also wait generous amount of time between the different operations, to be easy on the device drivers or whatever else is so fragile here. That has no positive effect either, apparently.

I've been getting this error for however long I can remember, at least one year now, but it's only now I feel I have grown impatient enough to report it here.

Firefox 87.0 x86-64 on Windows 10 1909.

(The error I get is from the second attempt to call getUserMedia above)

Is there any ETA for the fix ? Only Chrome works not the Edge & FF.

It seems the issue was with multiple browsers accessing the device(s) when opening same web page. It works when closed all the tabs for the page in all other browsers except FF.

This is weird. I'm testing on my linux desktop and my windows laptop (Windows 10, and I don't have the error above, it always work consistently.

It sounds like in your case Firefox is failing to release something and the second time we request it, it's already used and errors out. Would you be willing to get us logs of your machine so that we can try to understand what's up?

Flags: needinfo?(armen.michaeli)

In my case, this has nothing to do with multiple browsers or even multiple instances or windows/tabs of Firefox.

I have now narrowed it down to the... protocol over which the document hosting the script is served. If I serve the same document I quoted in my last comment over HTTP (http:) as opposed to file:, I get the "DOMException" error with the message "Starting video failed". I havent experimented with HTTP headers for the response, request headers are, for reference:

Host: localhost
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
Accept-Language: en,no;q=0.7,ru;q=0.3
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Pragma: no-cache
Cache-Control: no-cache

Response headers for the HTML document:

HTTP/1.1 200 OK
Server: nginx/1.15.9
Date: Wed, 28 Apr 2021 13:10:04 GMT
Content-Type: text/html
Content-Length: 675
Last-Modified: Wed, 28 Apr 2021 13:08:23 GMT
Connection: keep-alive
ETag: "60895e47-2a3"
Accept-Ranges: bytes

To clarify, I don't get the "starting video failed" error when using the document over file:, but I do over http:. This is weird. I recall reading of Chrome applying some extra permission restrictions for device access when using file:, but I don't recall anything of the sort for Firefox nor would I imagine a "failed" message would be appropriate if this was a legitimate denial of device access request.

Flags: needinfo?(armen.michaeli)

Jan-Ivar, can you have a look at this? Both about whether this is expected, and maybe to improve the error message?

Flags: needinfo?(jib)

Just to add some new findings, although at this point I am probably adding noise -- I get all sorts of inconsistent results. Sometimes, over http:, I do get a stream, with both a video and an audio track. The audio track behaves as expected (microphone audio), but the video track -- although not muted and active judging from the MediaStreamTrack object's own properties:

enabled: true
id: "{e517d2cf-f0bf-4f13-874b-5843b925b907}"
kind: "video"
label: "Integrated Camera"
muted: false
onended: null
onmute: null
onunmute: null
readyState: "live"

-- carries no actual video animation, it's just black. If I open another the same page (over http:) in another tab and request the stream, the video track in another tab suddenly starts to carry actual video, progressing from black. So maybe this is some shared access issue, but given how this doesn't always happen -- routinely opening and keeping multiple tabs gets me the same stream, with animated video track and everything, without problems. I guess I am just lost as to potential causes, I can only offer observations.

, with a valid ID and everything -- basically indistinguishable from an otherwise "healthy" stream judging by the object itself --

I seem to no longer experience this issue (with the same workflow as before) with Firefox 88. Something elsewhere fixed this?

I don't think anyone at mozilla were ever able to repro this.

Armen, in comment 15 and comment 17 you said you were able to use getUserMedia over http in 87, but that I don't understand because getUserMedia is only available over https (The navigator.mediaDevices object is missing in http), which means you should see this error:

TypeError: can't access property "getUserMedia", navigator.mediaDevices is undefined

Now there are some non-standard prefs in about:config to enable getUserMedia in insecure contexts. Do you have any of them enabled perchance?

Flags: needinfo?(jib) → needinfo?(armen.michaeli)

I'm also unable to repro comment 0 using this fiddle. In step 5, instead of OP's AbortError - Starting video failed, I get the (correct) error:

NotReadableError: Failed to allocated videosource

...which goes away on refresh (hitting the Run button) once the competing app (Chrome running same fiddle) is closed. On Windows 10 with a Logitech BRIO.

Severity: S2 → S3
Priority: P1 → P2

I am (evidently contrary to my last comment) getting an DOMException with the message "Starting videoinput failed" from Firefox 89. I have observed that either of the following apply:

  • If I close the tab/window and use Ctrl+Shift+T/Ctrl+Shift+N to restore it, the error disappears -- I can obtain a camera/microphone stream
  • If I open another instance of Firefox, with a different profile, e.g. firefox.exe -P <other-profile-name> -no-remote, the instance opened may also obtain a stream

I am afraid I can't provide more information than that at the moment, but I am open for suggestions. I have been using Firefox for almost two decades now, exclusively, and I suppose this "pedantry" comes from love for the project :)

As a last resort, do you recommend I build Firefox and go to town debugging this myself? Can someone point me in the general direction of the module/translation unit the issue may lie at, in that case?

Flags: needinfo?(armen.michaeli)

Surely there is a something in your setup that affects the behaviour, and we can't reproduce, so I think it could be best to take a step back, and get the info from about:support (please provide the "raw data" via the button at the top). The rather important number of different setup available (OSes/hardware/driver/versions) mean that it's hard to get everything working always. You'd think that all that would be abstracted away by the OS, and this is true in theory, but not always in practice.

What OS are you running (Windows from the .exe above?). It seems that you're comfortable with the command line, so this makes getting logs easy. On the command line, run:

set MOZ_DISABLE_CONTENT_SANDBOX=1
set MOZ_LOG=MediaManager:4,timestamp
set MOZ_LOG_FILE=logs-firefox
C:\Program Files\Mozilla Firefox\firefox.exe # adjust if not in a standard path of course

If not Windows, it's more or less the same with the set keywords, there are environment variable in any case.

and then you can reproduce the scenario you're facing, noting the steps you're taking, so we can match the logs (that have timestamps) with what you're doing, and really get to the bottom of this. Also maybe the type of webcam and/or laptop if that's the case (if it's a built-in camera for example).

The file that handles this kind of thing (device access and permission for camera, microphone, screen capture, etc.) is https://searchfox.org/mozilla-central/source/dom/media/MediaManager.cpp.

Flags: needinfo?(armen.michaeli)

For me same problem in android version. It seems there is some delay when i call track.stop() and when calling getUserMedia again it fails with fail to start video device. Bug is also noticable in meet.google.com, when i try switch cameras between front and back camera. Also in my custom meet solution.

Hi, I'm getting a DOMException: Starting videoinput failed when using sequentially getUserMedia on Android with Firefox 91.1.0.

Example:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <script>
      async function test() {
        console.log("Test");
        async function sleep(n) {
          await new Promise((resolve) => setTimeout(resolve, n));
        }
        try {
          var stream = await navigator.mediaDevices.getUserMedia({
            video: {}
          });
          devices = await navigator.mediaDevices.enumerateDevices();
          console.log("Devices retrieved", devices);
          const cameras = devices.filter(
            (device) => device.kind === "videoinput"
          );
          stream.getVideoTracks().forEach((track) => track.stop());
          for (const camera of cameras) {
            console.log("Getting stream for camera: " + camera.deviceId);
            stream = await navigator.mediaDevices.getUserMedia({
              video: { deviceId: { ideal: camera.deviceId } }
            });
            console.log("Stream opened");
            stream.getVideoTracks().forEach((track) => {
              console.log("Track label: " + track.label);
            });
            await sleep(2000);
            for (const track of stream.getTracks()) track.stop();
            console.log("Stream stopped");
          }
        } catch (e) {
          console.error(e);
        }
      }
    </script>
  </head>
  <body>
    <input type="button" onclick="test()" value="Test" />
  </body>
</html>

Output:

13:15:55.205 Test 7q3wf.csb.app:18:17
13:15:56.144 Devices retrieved Array(3) [ MediaDeviceInfo, MediaDeviceInfo, MediaDeviceInfo ]7q3wf.csb.app:27:19
13:15:56.154 Getting stream for camera: kALmtQiyA8PCjT5sTKg5We52Fu/kSyGAkcfQAxAk72s= 7q3wf.csb.app:33:21
13:15:56.830 Stream opened 7q3wf.csb.app:37:21
13:15:56.832 Track label: Facing front:1 7q3wf.csb.app:39:23
13:15:58.837 Stream stopped 7q3wf.csb.app:43:21
13:15:58.846 Getting stream for camera: IR2CF5JjzELBOGM2H7xHVyzoiAJFGAw6ZUtzCxx3zmc= 7q3wf.csb.app:33:21
13:15:58.947 DOMException: Starting videoinput failed

The same code works fine with Chrome.

No longer blocks: webrtc-triage

I've got the same or similar issue: "Starting videoinput failed", although mine is on Linux and only when using a second webcam (a CamLink USB device).

One interesting thing about my setup is that each camera has a second metadata device, which might cause problems if the wrong /dev/videoX is selected for that camera. Some Dell laptops have this on linux, although possibly not the same issue as the original reporter was on Windows. See: https://askubuntu.com/questions/1123601/four-dev-video-entries-but-just-one-camera.

Another thing is that when the camera I've selected fails Firefox just loads the other webcam and uses that instead, despite permission not have been given for that one.

set MOZ_LOG=MediaManager:4,timestamp

Nice tip!

I ended up using export MOZ_LOG=MediaManager:4,CamerasChild:4,CamerasParent:4,timestamp:

[Child 944135: MediaSupervisor #1]: D/MediaManager EnumerateRawDevices Task: Getting video sources with real backend
[Child 944135: MediaSupervisor #3]: D/CamerasChild Cameras dispatch for IPC failed in FocusOnSelectedSource
[Child 944135: MediaSupervisor #3]: D/MediaManager FocusOnSelectedSource failed
[Parent 943936: CaptureThread]: D/CamerasParent Correctly sized Video shmem not available in DeliverFrame

Interestingly when I open the camera with guvcview --device /dev/video2 it skips some frames with the following as the camera stream is starting up:

V4L2_CORE: not decoding empty raw frame (frame of size 0 at 0x0x7f0240a35000)
V4L2_CORE: Error - Couldn't decode frame

Maybe a frame->raw_frame_size == 0 check is needed like the one in https://github.com/biotrump/guvcview/blob/91238fc09de5380657f2216157e94b0ecb4bfc70/gview_v4l2core/frame_decoder.c#L793-L795?

Maybe this bug isn't related to mine?

The strncmp in modules/video_capture/linux/video_capture_linux.cc appears to only be doing a truncated comparison and so returns the wrong device:

(gdb) break VideoCaptureModuleV4L2::Init
(gdb) l
92	          if (strncmp((const char*)cap.bus_info,
93	                      (const char*)deviceUniqueIdUTF8,
94	                      strlen((const char*)deviceUniqueIdUTF8)) ==
95	              0)  // match with device id
96	          {
97	            close(fd);
98	            found = true;
99	            break;  // fd matches with device unique id supplied
100	          }
101	        }
(gdb) p cap.bus_info
$45 = "usb-0000:00:14.0-12", '\000' <repeats 12 times>
(gdb) p deviceUniqueIdUTF8
$47 = 0x7fffacde2ce8 "usb-0000:00:14.0-1"

I am experiencing the same problem. I have several devices connected to my computer:

video: rtc: (videoinput): Rift Sensor: CV1 External Camer id = JLL9FcQhPTV4MgDd989xCB0NpcDwQRajd7ziAGoXHAM=
video: rtc: (videoinput): Rift Sensor: CV1 External Camer id = M9ODxZYZA9cTgRStLIzzuSL3iVQRyy1pjuElido7Czw=
video: rtc: (videoinput): USB Camera-B4.09.24.1 id = P1Xk2CEsnEISk9ZNm8nWpHB1sQ8hvQsym9mdPKyMmsk=
video: rtc: (audioinput): Monitor of Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] Digital Stereo (HDMI) id = YWJZ/3dVsTyocqMh+in4n6UzP+aIMuzSHAidBVdaA6M=
video: rtc: (audioinput): Monitor of SMSL Q5 AMP Analog Stereo id = mAgMFd2ZfvqFoJyMTNS/yOxUnDckaUrcW5HeTA95dn4=
video: rtc: (audioinput): Sony Playstation Eye Multichannel id = S9TnVGueSHTga2KcDSBe1JCYqv3uY2mCJzhd6AU19zg=

I tried getUserMedia width default constraints (video: true, audio: true) but only got "Starting video input failed" . I tried to assign IDs { facingMode: "user", deviceID: "P1Xk2CEsnEISk9ZNm8nWpHB1sQ8hvQsym9mdPKyMmsk=" but got the very same response. I can't find any way to get the camera working. No problems with Chrome. Audio works without Problem.

Linux: Debian 4.19.208-1
Firefox: 95.0.2 (64-bit)

Is there any fix in the works, or workarounds? Seems like a severe issue to be sitting idle for a year.

Redirect a needinfo that is pending on an inactive user to the triage owner.
:jib, since the bug has high priority and recent activity, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(steven.michaels) → needinfo?(jib)

Redirect a needinfo that is pending on an inactive user to the triage owner.
:jib, since the bug has high priority, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(armen.michaeli) → needinfo?(jib)

Any news?

Thanks

Flags: needinfo?(jib)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: