DetectRTC
DetectRTC copied to clipboard
iOS 13.4 navigator.mediaDevices.enumerateDevices resulting in hasWebcam = false
Hi, folks!
We are having issues with DetectRTC.hasWebcam
. DetectRTC is calling navigator.mediaDevices.enumerateDevices
multiple times. That conflicts with a strange behaviour/bug on iOS 13.4. DetectRTC loops trough the media devices after 1+n call of navigator.mediaDevices.enumerateDevices
so webkit only returns MediaDeviceInfo having
kind: "audioinput"
. This leads to DetectRTC.hasWebcam = false
.
To reproduce this open the Safari Remote Webinspector and execute navigator.mediaDevices.enumerateDevices();
in the console.
First Call:
MediaDeviceInfo {deviceId: "", kind: "audioinput", label: "", groupId: "", toJSON: function}
MediaDeviceInfo {deviceId: "", kind: "videoinput", label: "", groupId: "", toJSON: function}
Second call:
MediaDeviceInfo {deviceId: "", kind: "audioinput", label: "", groupId: "", toJSON: function}
MediaDeviceInfo {deviceId: "", kind: "audioinput", label: "", groupId: "", toJSON: function}
We're seeing similar behavior on MacOS Safari 13.1, with DetectRTC.hasWebcam = false
there too.
This happens in Safari 13.1 on iOS 13.4, iPadOS 13.4 and MacOS 10.15.4.
Whereas it does not happen on iPadOS 13.3.1.
But it only happens in Safari 13.1 when camera is not set to "allow" in website settings.
So I guess that from now on one can only get device information after access has been granted. Chrome (Desktop & Android) and Firefox expose device information regardless of website settings.
Still seeing this on iOS 13.4.1
Indeed same here one IOS 13.4.1
I did some workaround in my own code and removed DetectRTC dependency. Maybe useful for other people: https://github.com/kasperkamperman/MobileCameraTemplate/issues/9
Indeed Safari first needs permission (getUserMedia) before enumerateDevices returns the correct data. https://webrtchacks.com/guide-to-safari-webrtc/
iOS 13.5 and subsequent versions don't seem to exhibit this issue anymore.