Fatal error! BSOD if trying to send midi message to a closed port
vfxturjo opened this issue · 10 comments
hi.
i hope you are fine
i am trying to create a midi instrument app with svelte + jzz,js, everything was going okay until i found this huge problem.
using jzz.info() i get the list of open ports and connect to it. i am currently using midiview for diagnosing the messages. ( https://hautetechnique.com/midi/midiview )
MidiView creates a midi port "MidiView" when opened. then when closed, it closes the midi port.
after connecting, i have a button that when pressed, it sends midi message to certain port
try {
outPort.note(0, 'C5', 127, 1000);
} catch (TypeError) {
alert('Midi device not ready');
}
here, outPort is already connected to the port choosed by a dropdown, using:
outPort = JZZ()
.openMidiOut(name)
// error logging
.or(function () {
alert("Cannot open MyMidiOut!\n" + this.log());
OutPortName = "error";
})
.and(refreshPortNames)
where "name" is the variable holding my choice of midi device (currently "MidiView")
after choosing it, the outPort variable is bound to the port. the midi send button works, but if i for some reason close MidiView software, then pressing the button causes my laptop to go on BSOD error.
this is dangerous
i want to track/monitor the port removal. especially the port that i am connected to. how to do this??
please help
I found a way to recreate the situation:
- install -> https://hautetechnique.com/midi/midiview
- open MidiView software
- go to -> https://jazz-soft.net/demo/SelectMidi.html
- select midi out device = MidiView,
midi in device = HTML keyboard - play random for few seconds and monitor if it is connected
- close MidiView window (this will close "MidiView" ports)
- see that the port is still connected
- play random notes again (u may see BSOD... else continue)
- after that, open MidiView software. (it will open the ports again)
- see that in the browser, the "MidiView" port is still connected but pressing the keyboard keys doesn't send midi to MidiView software
- so, try to reconnect the port by selecting "Midi Out" dropdown and selecting "MidiView" port again.
- BSOD happens
in the app that i am trying to make, i am facing this problem again and again. i faced BSOD around 10 times (never faced BSOD in this laptop before, and currently BSOD happening only if trying to send midi message to closed Midi Port).
i also tried to see if the midi send code returns error after MidiView is closed.
try {
outPort
.note(0, 'C5', 127, 1000)
.or(() => alert('cant send bro')) // <---- here
.and(() => {
alert('sent!');
});
} catch (TypeError) {
alert('Midi device not ready');
}
but it showed me "sent!", even after MidiView is closed. then after 1-2 seconds, i faced BSOD.
I need to monitor the device changes. onChange() method can see the "MidiView" port when i open the MidiView software, but it is not triggering when i close MidiView software (not working for "port removed/disconnected")
please help...
sorry to bother you with lots of comments. i am just trying to give you contexts so it will be easier to fix,
i think this is related:
Node.js exits with a "segmentation fault: 11"-Error when closing a midi-application whose (virtual) midi-ports where already recognized by JZZ's watcher.
This happens when JZZ.js runs within my node application, then I open e.g. the DLS-Midi Synth App on Mac and the port 'DLS-MIDI-Synth Virtual In' shows up in JZZ's list of available ports. Now, when I close the DLS-Midi Synth App, my node application exits with the segmentation fault.
i think this problem is similar. In Node.js, it is showing "segmentation fault", but in my case (working in MS Edge) it is resulting as BSOD...?
Can you try doing the same thing with a real MIDI instrument, i.e. plugging and unplugging it?
Will it also result in BSOD or is it MidiView specific?
🤔 didn't try that one. as i don't have any real Midi instrument, i will try to somehow use my android phone as as a midi port.
lets see if the problem still happens...
i just did that. used android phone as midi receiver.
used "FluidSynth MIDI" app to react to the midi signal received.
it detects when device connected/disconnected. refreshes the selection list when device is added/removed.
nothing happens when trying to send midi signal to a closed port.
i'm sorry to waste your time. it is not the problem of JZZ.js
your code is clean and amazing <3
Thanks for flattering :)
You may want to contact the MidiView developers to inform them about the problem.
For testing with virtual MIDI devices you can try
https://github.com/jazz-soft/midi-test (Mac and Linux only) or
https://github.com/jazz-soft/web-midi-test (may be a little trickier to setup your test)
thanks! i will inform the MidiView devs cz BSOD is dangerous.
although out of topic, i want to ask a question:
how to create a midi port?
currently i am using LoopMidi to create virtual midi ports. but, is there a way to create midi ports with browser so that my DAW can see the port directly without using LoopMidi?
it will be very useful if my app itself shows up as a midi device in the DAW and i can just listen to it from the DAW, as if i connected a real midi device into my laptop...
i'm on windows...
Creating MIDI port is difficult in Windows.
On Mac and Linux - you can see the source code in the midi-test I mentioned before (or you can just use it).
bad luck for me then... anyway, thank u for your time. i will create new issue when i face new problems. stay well 🥰