Re: [mediacapture-main] Should devicechange fire when the device info changes? (#966)

I think @youennf is on to our disconnect: he says what I want never worked. That is a key insight.

> In that use case, what we are after is a way for the web application to know what triggered the devicechange event.

Yes.

> Given the web app has an empty list returned by enumerateDevices prior the getUserMedia call, it cannot compute this information by calling enumerateDevices again.

That's not a satisfying answer, because apps will try even if they cannot compute it _accurately_, which seems like a design flaw.

In Firefox and Chrome, the app knows that a user-initiated action MUST have happened or it wouldn't have received the event. In Safari it doesn't have this information.

> Maybe there is a change of default input,

I count that as a valid user-initiated action worth reacting to (e.g. macOS seems to reorder defaults in response me taking my AirPods out).

> or a removal of an unused device, how can the web app know?

Here you've stumped me. Yes, it's possible that with 3 or more devices of a kind, removal of a 3rd device upon joining a meeting might be misinterpreted as insertion of the 2nd.

Your argument is basically: it won't work anyway. :)

But I prefer, it won't work anyway, so let's fix it. Not, it won't work anyway, so let's not.

> Also, the web application needs anyway logic to understand why devicechange fired (say a device that is not capturing is removed...), 

Yes. Let's talk about how complicated writing said code already is, and what a web compat nightmare it must be. Take this [this fiddle](https://jsfiddle.net/jib1/yvj4narc/), but keep AirPods in their case before opening it, then put them on. This is on macOS entura:

Firefox:
```
Switching to inserted AirPods
```
Chrome:
```
ignoring duplicate event
Switching to inserted AirPods
AirPods removed; reverting to Default - AirPods
Default - MacBook Pro Microphone (Built-in) removed; reverting to Default - AirPods
```
Safari:
```
MacBook Pro Microphone removed; reverting to MacBook Pro Microphone
Switching to inserted AirPods
```

I think it's quite hard to reason about both this application code and browser behaviors here, and I suspect there's a lot we could do.

To start, just to cut down on races, it might help to mandate NOT fire a `devicechange` event while a call to `enumerateDevices` is outstanding...

-- 
GitHub Notification of comment by jan-ivar
Please view or discuss this issue at https://github.com/w3c/mediacapture-main/issues/966#issuecomment-1734133569 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 25 September 2023 16:56:53 UTC