Created attachment 363082 [details] Not working safari 12.1 Hi Safari team, I'm facing issue with `navigator.mediaDevices.enumerateDevices` in Safari 12.1 as not able to get the device Ids when website permission is set to ask for devices. When we set website permission to allow for devices, it works. However, the same is working on Safari 12.0. So, I'm suspecting something has been introduced in Safari 12.1. Below is the test code executed into Safari console for testing : { navigator.mediaDevices.enumerateDevices().then(function(devices) { devices.forEach(function(device) { console.log(device.kind + ": " + device.label + " id = " + device.deviceId); }); }) }
Hi Pradeep, You are right. We changed a bit our fingerprinting enumerateDevices mitigation. I would be interested in your feedback there. Device IDs should now remain stable after getUserMedia is granted even after page reload. The device IDs will only be communicated after getUserMedia being granted. That should allow picking the same device as previously as follows: let stream; let deviceId = window.localStorage.getItem('preferredMicrophoneId'); const constraint = deviceId ? {audio : {deviceId: {exact: deviceId}}} : {audio: true}; try { stream = await navigator.mediaDevices.getUserMedia(constraint); } catch (e) { // In case of overconstrainederror, call getUserMedia({audio: true}) } deviceId = stream.getAudioTracks()[0].getSettings().deviceId; window.localStorage.setItem('preferredMicrophoneId', deviceId);
(In reply to youenn fablet from comment #1) > Hi Pradeep, > > You are right. > We changed a bit our fingerprinting enumerateDevices mitigation. > I would be interested in your feedback there. > > Device IDs should now remain stable after getUserMedia is granted even after > page reload. > The device IDs will only be communicated after getUserMedia being granted. > That should allow picking the same device as previously as follows: > > let stream; > let deviceId = window.localStorage.getItem('preferredMicrophoneId'); > const constraint = deviceId ? {audio : {deviceId: {exact: deviceId}}} : > {audio: true}; > try { > stream = await navigator.mediaDevices.getUserMedia(constraint); > } catch (e) { > // In case of overconstrainederror, call getUserMedia({audio: true}) > } > deviceId = stream.getAudioTracks()[0].getSettings().deviceId; > window.localStorage.setItem('preferredMicrophoneId', deviceId); Hi Youenn, Thanks for quick reply. The work around, you are suggesting, it works.
*** Bug 198148 has been marked as a duplicate of this bug. ***