PSA: Changes to enumerateDevices() in Chrome 86

1,106 views
Skip to first unread message

gui...@webrtc.org

unread,
Jul 8, 2020, 9:49:57 AM7/8/20
to discuss-webrtc
Starting with Chrome 86, enumerateDevices() will expose device info only if a previous getUserMedia() call has successfully completed.
Prior to Chrome 86, enumerateDevices() exposed devices if the domain had permission to access devices (e.g., from a previous browsing session), even if no previous getUserMedia() call had been performed.
This change aligns Chrome with the Media Capture and Streams spec and with the other major browsers.

Guido Urdaneta

unread,
Jul 29, 2020, 3:51:41 AM7/29/20
to discuss-webrtc
This change is now enabled in the latest Chrome Canary (86.0.4216.0).

Dag-Inge Aas

unread,
Jul 29, 2020, 6:33:19 AM7/29/20
to discuss...@googlegroups.com
Just tested this on Confrere and Whereby in Canary.

This change breaks (unsurprisingly) showing a primer if the gUM permissions have never been granted (See examples at the bottom).

It breaks because services have so far been forced to check for the presence of labels in enumerateDevices to know if a primer is needed to explain the permission prompt to users in most browsers. This is quite a common UX so I suspect more services are affected by this also. 

I see that support for "camera" and "microphone" in the Permission API has been rolled out in Chrome (unsure of version), so to fix this, you can change your code to use the Permission API where available:

navigator.permissions.query({name:'camera'}).then(function(result) {
  if (result.state === 'granted') {
    getUserMedia();
  } else if (result.state === 'prompt') {
    showPrimer();
  }
});

See also https://w3c.github.io/permissions/#media-devices.

image.png
image.png

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/5c9ae1f9-20dc-453d-ab69-058edfe6697fo%40googlegroups.com.


--
Dag-Inge Aas
CTO Confrere

gui...@webrtc.org

unread,
Jul 31, 2020, 6:27:24 AM7/31/20
to discuss-webrtc

We have decided to postpone this change, since we have had reports that it breaks at least one currently supported use case without a reasonable workaround. 
The case is a web site that requests permission using getUserMedia(), the user grants permission, but gUM() fails due to another reason (e.g., NotReadableError because the default device could not be opened).
In this case (e.g., a default device that fails), it becomes difficult, if not impossible, to proceed using any other device using Chrome's permission model. More details at https://crbug.com/1111333
Therefore, enumerateDevices() in Chrome 86 will continue to have the same behavior as in 85. 

Philipp Hancke

unread,
Aug 25, 2021, 5:50:38 AM8/25/21
to discuss...@googlegroups.com
please note (since I've just seen this on stackoverflow and not for the first time) that file:/// behaves a bit weird and will continue to restrict enumerateDevices after getUserMedia.
Don't use file:/// for anything important ;-)

Reply all
Reply to author
Forward
0 new messages