Hi,
When using AudioDeviceManager for MIDI input/output in a plugin, removing a plugin instance and adding a new one causes MIDI communication to fail. The new instance cannot communicate with MIDI.
JUCE Version: 8.0.12 (works correctly in 8.0.10)
Operating System: macOS 15.7.3
Steps to Reproduce:
- Create a VST3/AU plugin that uses AudioDeviceManager for MIDI I/O
- In the plugin editor, create an AudioDeviceManager and enable MIDI device:
audioDeviceManager = std::make_uniquejuce::AudioDeviceManager();
audioDeviceManager->setMidiInputDeviceEnabled(deviceIdentifier, true);
audioDeviceManager->addMidiInputDeviceCallback(“”, this); - In the destructor, clean up properly:
audioDeviceManager->removeMidiInputDeviceCallback(“”, this);
audioDeviceManager->setMidiInputDeviceEnabled(deviceIdentifier, false);
audioDeviceManager.reset(); - Load plugin in DAW (tested in Ableton Live, Logic Pro)
- Verify MIDI communication works with first instance
- Remove the plugin instance from the DAW
- Add a new instance of the same plugin
- Result: New instance cannot communicate with MIDI device
The new plugin instance fails to receive MIDI from the device. The device appears to be in a bad state after the first instance is removed.
This appears to be related to the UMP (Universal MIDI Packet) rewrite in 8.0.11. Specifically, the session-based approach in juce_MidiDevices.cpp:
static std::shared_ptrump::Session getLegacySession()
{
static std::weak_ptrump::Session weak;
// …
}
The global weak pointer may not properly handle cleanup when a plugin instance is destroyed, leaving the session in an inconsistent state for subsequent instances.
Reverting to JUCE 8.0.10 resolves the issue.
Notes:
- Plugin is a VST3/AU instrument/effect
- Uses AudioDeviceManager rather than the plugin’s built-in MIDI
- Issue does NOT occur when switching between existing instances, only when removing and creating new instances
Thank you!
