Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chrome's webkitGetUserMedia - what if the user ignores the dialog?

So the standard way that navigator.webkitGetUserMedia is used is like such:

function success() {
    console.log('User accepted');
}

function deny() {
    console.log('User rejected');
}

navigator.webkitGetUserMedia({video: true, audio: true}, success, deny);

The site I'm developing absolutely needs the use of the user's webcam and microphone (actually, using Flash, but that seems to go through this API now), so I'm trying to do everything to ensure the user always knows what they need to click for the site to work.

  • If neither function is called, assume the dialog is showing, and display instructions to the user.
  • If deny is called, explain that webcam access is needed, and show them they can click the camera icon in Chrome's URL bar to change their decision.
  • Of course, if success is called, then the user has accepted, and continue as normal.

Here's the kicker; and you could follow along by pasting the above Javascript into any site you like (in Chrome). If the user navigates to a new webpage, or refreshes the current page without either accepting, denying, or dismissing the dropdown, they will not see a permissions dialog again for the current domain for the browser session.

Calling navigator.webkitGetUserMedia(...) again will not show a permissions dialog, nor will the camera icon even appear in the URL bar. The console doesn't even log "User rejected". What's more, for many users this dropdown is very easy to accidentally ignore. The only fix available is to close the browser entirely and re-open it (or, to manually navigate through complicated settings menus that we DON'T want to force our users into).

Can I confirm with anyone here whether this is 'somehow' intended, or if there's something I'm missing?

like image 981
Katana314 Avatar asked Jul 10 '13 17:07

Katana314


People also ask

How to ask Camera permission in Web?

Chrome BrowserIn a new tab, type in "chrome://settings/content". This will take you to the Site settings. Scroll down to the Permissions section and click either Camera or Microphone. Set to "Ask before accessing (recommended)".

What is navigator Webkitgetusermedia?

The deprecated Navigator. getUserMedia() method prompts the user for permission to use up to one video input device (such as a camera or shared screen) and up to one audio input device (such as a microphone) as the source for a MediaStream .

How do I know if my webcam is on javascript?

getUserMedia({ video: true }, () => { console. log('has webcam') }, () => { console. log('no webcam') }); to call it with { video: true } and callbacks that's run if a webcam is present and if the webcam isn't present respectively.

How do I enable my Camera on my Mac for Chrome?

Enable Camera and Microphone on my Mac (for Chrome) Print First, click the apple icon on top left corner > Select System Preferences... from the menu. Then click Security & Privacy. Click Privacy tab. Click Camera in the lefthand column, then tick the box next to Google Chrome.


1 Answers

It seems that this is a known bug.

Issue 252904: Infobar popup on mic/cam permission results in unexpected permission state; causes unrecoverable lack of permission on reload

There are currently two patches in the comment thread on that bug, so at least you know they are working to fix the issue. Unfortunately there don't appear to be any real workarounds for the bug in the mean time.

One thing worth mentioning: if you close the tab and then reopen the url, that does seem to force the permission dialog to show again. I know that's not a real solution, but at least it's better than closing the whole browser (which I think is what you've been doing up to now).

like image 173
James Holderness Avatar answered Sep 19 '22 12:09

James Holderness