MIDI device fails to reconnect after plugin instance removal on macOS (J 8.0.11 & 8.0.12)

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:

  1. Create a VST3/AU plugin that uses AudioDeviceManager for MIDI I/O
  2. In the plugin editor, create an AudioDeviceManager and enable MIDI device:
    audioDeviceManager = std::make_uniquejuce::AudioDeviceManager();
    audioDeviceManager->setMidiInputDeviceEnabled(deviceIdentifier, true);
    audioDeviceManager->addMidiInputDeviceCallback(“”, this);
  3. In the destructor, clean up properly:
    audioDeviceManager->removeMidiInputDeviceCallback(“”, this);
    audioDeviceManager->setMidiInputDeviceEnabled(deviceIdentifier, false);
    audioDeviceManager.reset();
  4. Load plugin in DAW (tested in Ableton Live, Logic Pro)
  5. Verify MIDI communication works with first instance
  6. Remove the plugin instance from the DAW
  7. Add a new instance of the same plugin
  8. 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!

Thanks for reporting, that’s fixed on the develop branch here: