I am trying to write a macOS app that hosts and controls various AudioUnit MIDI instruments, allowing the user to interact with them including using their GUI. I have gotten my app loading the units, connecting them into an AVEngine and playing MIDI notes on them, as well as opening the instrument's GUI (using AUAudioUnit's requestViewController method).
It works fine for most AudioUnits, but a few (mostly from Native Instruments) crash in the GUI code. Opening Massive and loading a preset from its dropdown menu, or opening Reaktor and loading an ensemble, or just instantiating and opening the GUI of Absynth, causes an EXC_BAD_ACCESS in the main thread, in objc_msgSend. This appears to have been called from AUBase::PropertyChanged(unsigned int, unsigned int, unsigned int), as a result of some of the plugin's properties changing. (In Massive, the third call frame is in a method named NI::MASSIVE::MassiveInstrument::onMacroNameChanged(int). So it appears that this is happening as a side-effect of Native Instruments' preset management code.
This problem also happens in the AudioUnitV3Example sample code from Apple, in the same way. It appears that the example AudioUnit V3 host code doesn't handle something correctly, something that commercial apps like Logic and Ableton Live handle without problems. Does anybody know what the problem could be?