- From: Jan-Ivar Bruaroey via GitHub <sysbot+gh@w3.org>
- Date: Mon, 27 Apr 2020 21:23:51 +0000
- To: public-webrtc-logs@w3.org
> As of detecting whether there is a new device or not, this is easy to determine. In the new device detection algorithm, if the previous list of devices is empty or devices have empty device ids, there is no new device. That seems incorrect for detecting insertion both _before_ & _during_ (shortly after) getUserMedia: 1. **Before:** event fires ([works](https://jsfiddle.net/jib1/nj0w2sq1/) in Edge; Chrome, Safari & [Firefox](https://bugzil.la/1397977) are non-compliant) 2. **During:** How can you know the device wasn't just inserted? (may have gone from 0 to 1 device) The _"new devices detection"_ algorithm for most years of this spec has been a simple subtract: ```js let old = await navigator.mediaDevices.enumerateDevices(); navigator.mediaDevices.ondevicechange = async () => { const devices = await navigator.mediaDevices.enumerateDevices(); const newDevices = devices.filter(d => !old.find(o => o.deviceId == d.deviceId)); old = devices; }; ``` Expecting web devs to do more than that seems ambitious. As I recall, the use-cases are: 1. **Pre-gUM:** User inserts a device for which they had none before, qualifying them for feature. 2. **Post-gUM:** User inserts a device (e.g. headset) preferred over the one they have now. We should not break those IMHO. How do you propose we support those? > Some web applications may buffer enumerateDevices result and only update it based on the device change event. That would be a silly thing to do when _enumerateDevices_ already buffers (see [storedDeviceList](https://w3c.github.io/mediacapture-main/getusermedia.html#ref-for-dfn-storeddevicelist-3)). But it does point to a spec problem: The list is [not allowed to be updated](https://w3c.github.io/mediacapture-main/getusermedia.html#ref-for-dfn-storeddevicelist-1) without an event. So we broke something when we went: 1. from a simpler world where the list only changed when devices were inserted/pulled, and the event signified both 2. to a world where the event can no longer mean both. It's now unclear what the event means. It's lost it's meaning. -- GitHub Notification of comment by jan-ivar Please view or discuss this issue at https://github.com/w3c/mediacapture-main/issues/688#issuecomment-620242987 using your GitHub account
Received on Monday, 27 April 2020 21:23:52 UTC