DetectRTC icon indicating copy to clipboard operation
DetectRTC copied to clipboard

iOS 13.4 navigator.mediaDevices.enumerateDevices resulting in hasWebcam = false

Open denkerinteraktivgmbh opened this issue 4 years ago • 6 comments

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.enumerateDevicesso 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}

denkerinteraktivgmbh avatar Apr 02 '20 09:04 denkerinteraktivgmbh

We're seeing similar behavior on MacOS Safari 13.1, with DetectRTC.hasWebcam = false there too.

TyLindberg avatar Apr 02 '20 18:04 TyLindberg

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.

HiddenType avatar Apr 04 '20 13:04 HiddenType

Still seeing this on iOS 13.4.1

atav32 avatar Apr 24 '20 00:04 atav32

Indeed same here one IOS 13.4.1

nemoneph avatar May 16 '20 17:05 nemoneph

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/

kasperkamperman avatar May 17 '20 13:05 kasperkamperman

iOS 13.5 and subsequent versions don't seem to exhibit this issue anymore.

willmorgan avatar Sep 24 '20 12:09 willmorgan