Closed belm0 closed 6 years ago
@belm0 I was able to reproduce the problem on Chrome 61/Windows 10. It seems to be coming from upstream. I'll have to do more tests to be sure but as far as I can tell Chrome is not firing those events at all... I'll try it on Linux and macOS and see if there's a difference. Which platform are you on?
Thanks for reporting.
I'm seeing it on OS X Sierra with Chrome 61.
After re-reading the spec and looking at various use cases, I am concluding that it would be more logical if the connected
and disconnected
events only fired when a device is actually being connected or disconnected. If you load a page while devices are already connected, it should not fire the connected event. There's no real point to it anyway since we can simply look at WebMidi.inputs
and WebMidi.outputs
to know what's available.
Obviously, if a device is added or removed later on, the events will be fired. I commited a new version which works in this way. Perhaps you can try it and let me know what you think.
P.S. I need to do a few more tests before actually releasing it on NPM.
The behavior up until now was convenient, since I could just implement the connected
event to handle both the case where device is already connected at init and where device is connected afterwards.
Would you share some background on the decision to change semantics?
I totally understand your position. Let me think about it a little...
Okay, I think I found a way to meet your needs. Can you try the new latest committed version to confirm it works for you?
This version triggers connected
events for both inputs and outputs.
If you still want some background info, you can check the comments I added for myself in the code.
I have not heard back from OP so I'm going to assume that the fix is satisfactory and close this bug report.
I was able to confirm this fix finally, thank you.
I have a MIDI controller which happens to also posses an output port for configuration.
When I enable WebMidi I only receive a connected event for the input port. Subsequently disconnecting the device, I do received disconnected events for input & output, and again receive both when I reconnect.
Following is logging of WebMidi events.