WebAudio / web-midi-api

The Web MIDI API, developed by the W3C Audio WG
http://webaudio.github.io/web-midi-api/
Other
325 stars 49 forks source link

Are `MIDIInputPort` and `MIDIOutputPort` populated during `requestMIDIAccess` ? #231

Open padenot opened 2 years ago

padenot commented 2 years ago

Gecko's implementation populates the MIDIAccess' ports asynchronously w.r.t requestMIDIAccess() call. It can therefore be that the promise returned from requestMIDIAccess is resolved, without ports being available. Later, onstatechanged is fired correctly, then the ports are added.

Reading the code, it seems like Chromium resolves the promise returned by requestMIDIAccess() after enumeration, is that right? It's probably something that we'd want clarified. It seems like a useful property.

djipco commented 2 years ago

I'm not sure which way is best but I agree that it should be clarified in the spec since developer expectations will most likely diverge on this topic.

djipco commented 2 years ago

Generally-speaking, is there an advantage for Gecko to do it asynchronously? Does this advantage outweigh the fact that it introduces an incompatibility between implementations?

padenot commented 2 years ago

I don't think there is, it waiting isn't in the spec, so we didn't implement it, the Promise is tied to the permission acceptation in our implementation, not the enumeration.

This part of the spec is a bit hand wavy, there's no explicit enumeration steps, and thus it's unclear when to resolve the promise. This can be changed, and we can fix our implementation to resolve slightly later.

djipco commented 2 years ago

Per you last comment, it is now clear that the spec should be updated to clarify the sequence. I suggest we align the spec with Chromium's existing behaviour so we do not introduce an unnecessary incompatibility.

cwilso commented 2 years ago

That would seem best, yes. Of course, the MIDI ports may change asynchronously, but it's probably better to have the initial list when the MIDIAccess is populated.

hoch commented 1 year ago

Teleconference 4/6: We can add additional steps to clarify the timing of port population between Step 6 and Step 7 in the algorithm of https://www.w3.org/TR/webmidi/#requestmidiaccess.

mjwilson-google commented 1 year ago

Audio Working Group 2023-10-05 meeting conclusions: