Closed intonarumori closed 1 week ago
Quick update:
I was able to fix the crashes by using these two parts of the MIDIApps code:
nil
returned from MIDIPacketListAdd
I will see if I can simplify the code a little bit, it looks like we have to introduce some Obj-C helpers.
Thank you for diving into this issue.
Splitting large arrays of data into smaller ones should not be a big challenge.
However, I am a little confused as to why sending multiple 512 bytes SysEx chunks causes the system to crash.
Mostly because every send
call creates its own MIDIPacketList
and puts data into that. (I can see some other potential issues here though). This must mean that there is further "queueing' deeper down the system ?
Alternatively, we should consider migrating to the never MIDIEventList
type on Apple's platforms, but that is probably a bigger undertaking.
@intonarumori please try out this branch which does packet splitting: https://github.com/InvisibleWrench/FlutterMidiCommand/tree/bugfix/coremidi_dealloc
@mortenboye I ran my example app and this looks to be working great.
Fix included in v. 0.4.16.
I've been working on a MIDI editor application and noticed crashes when sending larger SysEx messages. I traced down the issue to this line of code for iOS and macOS, see screenshot.
I looked at some other repositories for reference and here's what I found:
Takeaways so far
packet
value fromMIDIPacketListAdd
and handle errors accordinglyMIDIPacketListAdd
in Obj-C and makes the return typenullable
MIDIPacketListAdd
- I wonder if this is correctI've attached an example application, pressing "Sending 512 bytes" couple of times crashes the app for me, let me know if you can reproduce.
I will be looking into the issue to see if I can fix it as I have some existing Obj-C implementation that worked fine in the past.
Flutter Example for sending large SysEx messages
``` import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter_midi_command/flutter_midi_command.dart'; void main() { runApp(const MainApp()); } class MainApp extends StatelessWidget { const MainApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( home: Scaffold(body: HomeView()), ); } } class HomeView extends StatefulWidget { const HomeView({super.key}); @override State