Why can't I get the device ID on Chrome 81?
On Chrome 81, the deviceId
field that the getDevices
method returns is empty.
Reason
As of Chrome 81, device IDs are not exposed if permission to use devices has not been granted. This change is to protect user privacy.
For the Agora Web SDK, if you get device information before the method call of Stream.init
succeeds, the returned deviceId
may be empty.
Solution
You can create temporary streams for media capture to trigger the device permission request and get the device information.
-
Based on your requirements, create temporary streams for audio or video capture to trigger requests for microphone or camera permissions.
-
After the streams are initialized, call
getDevices
to get the complete device information.Note
The capture may fail if no microphone or camera exists, or if the user has disabled these devices. The capture is a workaround and you only need to ensure that the failure does not stop the code execution.
If the capture fails, you may still get empty
deviceId
andlabel
fields in the returned device list.