Closed Bug 1745575 Opened 3 years ago Closed 3 years ago

Not possible to determine between camera permission temporarily allowed, or not previously requested

Categories

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

Firefox 95
defect

Tracking

()

RESOLVED DUPLICATE of bug 957558

People

(Reporter: will, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36

Steps to reproduce:

On a single page app where I don't refresh:

In Firefox, I cannot determine the camera permission via the Permissions API interface. I also cannot determine it by inspecting the result of mediaDevices.enumerateDevices. The only way I can do this is to activate the camera, which may not be required or desired for the user if I want to limit the time the camera is active.

My app needs to open fullscreen and request permission, ideally simultaneously. However in Firefox, requesting camera permission takes the user out of fullscreen, so I need to request permission with one click, and then require another click to open fullscreen.

Therefore, I display a "grant permission" button to users where a click is required to bring up a camera prompt first.

From a user's point of view, my component is placed after another vendor's component which commonly requests camera permissions.

Therefore, as a user, if I request camera permission through getUserMedia, then close the stream on one single page app "state", then navigate to the next component, that next component has no way of determining whether I have temporarily allowed camera permissions.

As a developer, because Firefox doesn't support the Permissions API with the camera PermissionDescriptor, I display this if I run mediaDevices.enumerateDevices() and don't find any devices with a non-empty label (i.e. it is not "").

Actual results:

When I call mediaDevices.enumerateDevices():

  • In a "not requested" or "temporarily allowed" state, Firefox returns the real number of video inputs without labels.
  • In a "permanently allowed" state, Firefox returns the above, but with labels.

In a "not requested" state, Firefox displays a permission prompt, therefore the user needs to click to interact with this, which takes them out of fullscreen.

In a "temporarily allowed" state, Firefox doesn't display a permission prompt (AFAICS, as long as a user gesture happens), therefore the user doesn't need an extra click.

However, because it is not possible to determine permission, I need to display the "grant permission" button anyway, which could confuse users as permission is already granted, though there is no way to tell if another vendor "pre-warmed" the permission in their own SDK.

Expected results:

It would be useful if Firefox provided some way to indicate the "temporarily allowed" state without actually requiring the camera to activate.

In Safari and Chrome, this is done by providing non-empty InputDeviceInfo labels when a developer calls mediaDevices.enumerateDevices().

Alternatively, a cleaner implementation that doesn't rely on device sniffing would be for Firefox to implement the camera PermissionDescriptor.

The Bugbug bot thinks this bug should belong to the 'Core::WebRTC: Audio/Video' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

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

Hi Will, thanks for the thorough report! Firstly, sorry for this being so complicated, as there are many layers here. I think your use case makes sense, but see comments inline.

(In reply to Will Morgan from comment #0)

In Firefox, I cannot determine the camera permission via the Permissions API interface.

This is bug 1609427.

My app needs to open fullscreen and request permission, ideally simultaneously. However in Firefox, requesting camera permission takes the user out of fullscreen,

This is bug 957558, which seems to be the core issue and overdue for a fix. I've added some comments there to try to escalate it. Everything else here (including the subject line) appears to be a workaround for that issue (correct me if I'm wrong).

... I run mediaDevices.enumerateDevices() and don't find any devices with a non-empty label (i.e. it is not "").

Note this relies on side-effects that will break once we fix bug 1528042. This is required by spec now for privacy reasons: JS will no longer see labels until after the document has called getUserMedia, regardless of permission.

In a "temporarily allowed" state, Firefox doesn't display a permission prompt (AFAICS,

...with the caveat that "temporarily allowed" is per-device in Firefox, so it may still prompt depending on which camera is requested using constraints.

as long as a user gesture happens),

getUserMedia does not require user-gesture (but does require focus before it will resolve in Firefox).

In Safari and Chrome, this is done by providing non-empty InputDeviceInfo labels when a developer calls mediaDevices.enumerateDevices().

I believe this is incorrect regarding Safari, which now implements the more privacy-friendly spec, where labels are no longer tied to permission, but to active capture having happened.

I believe you're correct about Chrome, which is crbug 1101860.

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Depends on: 957558
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.