WebMIDIKit
WebMIDIKit copied to clipboard
Removing a Midi Device produces a crash
The problem is here:
Assertion failed: file WebMIDIKit/MIDIPortMap.swift, line 72
The code:
assert(port.state == .connected)
Is this assertion necessary?
what code causes this crash?
Just physically removing a controller, no code of my own. I ended up just commenting that line. BTW, there were a few other lines that had to be fixed, the code did not compile at the beginning. Should I make a PR with those changes?
Oh yeah that makes sense actually. Yeah start a PR. Yeah the repo hasn’t been updated in some time.
Just found another crashing line, in Enum.swift line 32:
fatalError("You didn't initialize a virtual port")
This happens when closing a Virtual midi port. I've added a fix for the crash to the current PR.
I'm however not sure how to recognize the Virtual ports as input
and output
. When they connect, they recognize fine, only when disconnecting the type is returned as other
.
I think that there isn’t support for virtual ports right now.
Understood, but crashing the whole app when disconnecting a midi port is still not desired.
The Virtual ports actually do work (they show as Input and Output when connected), it's just hard to recognize when they disconnect, which is actually not that bad. I will try to see if I can figure this out.
It’s an implementation of the webmidi standard. You might be right, I should be caching the values. Do you want to do a pr?
Pull request.