New issue
Advanced search Search tips

Issue 627685 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Jul 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 1
Type: Bug



Sign in to add a comment

Camera access broken in dev

Project Member Reported by pdr@chromium.org, Jul 13 2016

Issue description

Version: 53.0.2782.9/dev
OS: Android

What steps will reproduce the problem?
(1) Open https://jsbin.com/saxoye/edit?html,console,output
(2) Click allow to the permission prompt for accessing the camera.
(3) You should see a video from the camera

What do you see instead?
Blank, no video

https://webqr.com/ is another site that is broken.
 

Comment 1 by mcasas@chromium.org, Jul 13 2016

Cc: mcasas@chromium.org
Components: Blink>Webrtc>GetUserMedia
Labels: Needs-Feedback
That's odd, I'm running ToT practically every day and
didn't have issues capturing. What's the hardware that
doesn't work? Is it also verifiable with [1]?

[1] https://rawgit.com/Miguelao/demos/master/gum_simple.html

Comment 2 by pdr@chromium.org, Jul 13 2016

This is on a Samsung Galaxy S7. I just double-checked the urls and the ones in the first post are still broken, but your sample works. Maybe we changed an API?

Comment 3 by pdr@chromium.org, Jul 13 2016

Labels: -Needs-Feedback

Comment 4 by mcasas@chromium.org, Jul 13 2016

#2: I think I know what the problem is, the code is falling
through  navigator.getUserMedia(videoObj, ...);
instead of using  navigator.webkitGetUserMedia(...), the 
former is promise based and the latter is old-school 
asynchronous functions.

Not 100% sure if you need 
chrome://flags/#enable-experimental-web-platform-features
enabled for the promise-based gUM to work, but probably
you have that one on :)

Comment 5 by mcasas@chromium.org, Jul 13 2016

Status: WontFix (was: Untriaged)
(forgot to say #4 refers to the code in https://jsbin.com/saxoye/edit)

Btw, for snapping a picture, you can also consider
takePhoto() or grabFrame() [2] directly on the MediaStream,
saving you the round trip through canvas :)

[1] https://github.com/miguelao/demos/blob/master/imagecapture.html#L63
[2] https://github.com/miguelao/demos/blob/master/imagecapture.html#L90

Comment 6 by pdr@chromium.org, Jul 13 2016

This seems to have broken many real websites. Do we know the scale of the breakage? These sites still work in Firefox.

I think we should reconsider WontFix.

Comment 7 by mcasas@chromium.org, Jul 13 2016

Cc: guidou@chromium.org foolip@chromium.org hta@chromium.org
Status: Untriaged (was: WontFix)
Adding some peeps to respond to the question in #6, 
hta@, guidou@, foolip@, WDYT? Do we have metrics of
the new API usage?

Comment 8 by pdr@chromium.org, Jul 20 2016

Cc: rbyers@chromium.org
Ping?

Comment 9 by foolip@chromium.org, Jul 20 2016

navigator.getUserMedia is actually not promise-based, it has the same success/error callback pair as navigator.webkitGetUserMedia. (navigator.mediaDevices.getUserMedia is promise-based.)

AFAICT, the problem in both https://webqr.com/ and https://jsbin.com/saxoye/edit?html,console,output is that video.src is assigned differently in both cases. When the prefixed API is used, webkitURL.createObjectURL is used, but when the unprefixed API is used, video.src is just set to the stream object.

IIRC, at some point in the discussion that led up to video.srcObject there was the suggestion to just allow setting video.src, but I don't think that ended up implemented anywhere. For whatever reason, this script mistakenly assumes that it's possible to set video.src to a MediaStream, and that can't be fixed.

Without changing the script, the only thing that could be done is to unship navigator.getUserMedia.

Do we have any clue about how common this problem is? pdr@, do you know of other cases?

Usage of this API is at https://www.chromestatus.com/metrics/feature/timeline/popularity/1401 but that doesn't say much about the prevalence of this coding mistake.

Comment 10 by pdr@chromium.org, Jul 21 2016

Thanks foolip. I got the code for that jsbin from the first hit on google for "html5 camera demo", https://davidwalsh.name/browser-camera. https://www.the-qrcode-generator.com/scan and the HTML5Rocks demos are broken too.

Maybe we could just update our docs (html5 rocks) and reach out to these sites?
http://www.html5rocks.com/en/tutorials/getusermedia/intro/ doesn't seem to have this specific problem in the article, but the demo fails at "navigator.getUserMedia('video', ...)" because "TypeError: Failed to execute 'getUserMedia' on 'Navigator': parameter 1 ('options') is not an object."

And then it actually would assign video.src = stream if it hadn't already failed.

pdr@, did you just stumble upon these sites, or did you search in a corpus? In other words, is this just the tip of the iceberg? I think we should be quite willing to revert navigator.getUserMedia, because navigator.mediaDevices.getUserMedia was also added at the same time and is the API that we "want" people to use as the first choice.

guidou@, hta@, thoughts?

Comment 12 by pdr@chromium.org, Jul 21 2016

foolip@, I stumbled on the QR sites during regular browsing; was trying to find a QR reader for testing my homepage. The jsbin repro I used was just naively copying code from the first hit on google (David Walsh's blog). There's a chance I just got unlucky.

Comment 13 by hta@chromium.org, Jul 21 2016

So the problem in the initial snippet is this:

if(navigator.getUserMedia) { // Standard
				navigator.getUserMedia(videoObj, function(stream) {
					video.src = stream;
					video.play();
				}, errBack);

The author wrote the code from what he imagined the standard would be. It never worked, in any browser. Perhaps there was a version of the standard that specified video.src = track; I know it was discussed on the list, but I can't remember ever publishing a version that had it.

Now the standard has changed from what he once thought it would be. And his trigger for "it claims to conform to the standard" has triggered.
The code has a bug.
I don't think we should revert because of a bug.

Similarly, line 798 of http://www.html5rocks.com/en/tutorials/getusermedia/intro/ has a pure bug: He forgot to put the {} around "video: true". Again, code never executed, not tested, has a bug.

I think we can't protect buggy code from itself forever. And given that the amount of code yet to be written is larger than the amount of code currently written, I think the Right Thing is to get the standards-compliant stuff out there ASAP, and let the bugs be found.

Comment 14 by pdr@chromium.org, Jul 23 2016

Status: WontFix (was: Untriaged)
Thanks for looking into this! It sounds like WontFix was the correct decision all along.

I will shoot off an email to Eric (html5rocks author) and do my best to contact the QR code sites as well.
If this pops up again and someone finds this issue, please comment so that we can consider whether the compat fallout is worth it.
Components: -Blink>Webrtc>GetUserMedia Blink>GetUserMedia

Sign in to add a comment