Description
While not documented in the coremidi crate, PacketBuffer has an intrinsic size limit based on a poorly documented and handled size limit in Apple's CoreMIDI MIDIPacketList and MIDIPacket structures. The size limit is a bit less than 65536. (Exact value isn't documented!)
MidiOutputConnection's send() takes whatever data is passed in and passes it directly to PacketBuffer. If the data is big (think 80k sysex messages) - then PacketBuffer creates a corrupted buffer, which when sent causes a hard crash.
If the semantics of send() are that it will send what ever it is handed... then it needs to break larger messages up into chunks, and send the one after another.
If the semantics of send() are that it wants to inherit the limits of PacketBuffer, then it should document, and perhaps enforce that constraint.
How did I find this? I'm sending 80k sysexs (to control a synth) from a WebMIDI app.... and in Firefox on Mac it crashes the browser completely and instantly! I don't know who to blame for the crash... but the 80k byte array gets passed:
JavaScript -> Firefox/Gekko's C++ code -> Firefox/Gekkot's Rust crate midir_impl -> Boodlnagg's Rust midir package -> coremidi