instascan icon indicating copy to clipboard operation
instascan copied to clipboard

Demo: why two confirmations for camera access?

Open leplatrem opened this issue 6 years ago • 7 comments

I was wondering why I am asked twice to allow the camera in the demo (whereas I have only one by the way)

Is it expected? Thanks :)

leplatrem avatar Dec 01 '17 09:12 leplatrem

Same problem here, not only in demo. Talking about mobile browsers, I've encountered this problem in Opera and Firefox, but not in Chrome.

mortche avatar Dec 01 '17 12:12 mortche

@leplatrem might be approval per camera - front and rear.

gsand avatar Dec 19 '17 22:12 gsand

I only have one though.

It could be one auth for listing the cameras, and another one when choosing one?

leplatrem avatar Dec 19 '17 23:12 leplatrem

I am experiencing this too, on demo and personal implementation. Across different browsers, tested in Firefox desktop and Chrome mobile.

A user has to click allow twice for camera permissions.

SmileyJames avatar Dec 13 '18 17:12 SmileyJames

Useful thread: https://stackoverflow.com/questions/15993581/reprompt-for-permissions-with-getusermedia-after-initial-denial

Note the comment "HTTPs on Firefox won't persist this permission."

Chrome on the demo, which has https, only requests permission once. When using Firefox or http you'll have to give permission twice.

SmileyJames avatar Dec 13 '18 19:12 SmileyJames

I think getCameras() requires a first permission request to just access the user medias list. Then start() requires a second one. This is on Firefox only as @SmileyJames wrote earlier because Chrome automatically persists the permission. The problem with Chrome is that on mobile it won't let you choose facing or environment cam. I have no good solution yet. :(

macmorning avatar Jan 31 '19 07:01 macmorning

The navigator.mediaDevices.getUserMedia() is called twice:

  • once when listing the cameras (through Camera.getCameras())
  • once from Camera.start(), and not with the same settings

That may be the reason. Change proposed with PR https://github.com/schmich/instascan/pull/213

optout21 avatar May 07 '19 09:05 optout21