MessageManagerLock deadlocks when opening arbitrary other plugin

My program is freezing on MessageManagerLock acquiring a lock, when I open any plugin (same or different) using the same DAW or AudioPluginHost.

What could be causing the interference between plugins?

	[External Code]	
>	FSynth.vst3!juce::WaitableEvent::wait(int timeOutMilliseconds) Line 40	C++
 	FSynth.vst3!juce::MessageManager::Lock::tryAcquire(bool lockIsMandatory) Line 344	C++
 	FSynth.vst3!juce::MessageManager::Lock::tryEnter() Line 302	C++
 	FSynth.vst3!juce::MessageManagerLock::attemptLock(juce::Thread * threadToCheck, juce::ThreadPoolJob * jobToCheck) Line 425	C++
 	FSynth.vst3!juce::MessageManagerLock::MessageManagerLock(juce::Thread * threadToCheck) Line 404	C++
 	FSynth.vst3!FSynthAudioProcessor::processBlock(juce::AudioBuffer<float> & buffer, juce::MidiBuffer & midiMessages) Line 487	C++
 	FSynth.vst3!juce::JuceVST3Component::processAudio<float>(Steinberg::Vst::ProcessData & data, juce::Array<float *,juce::DummyCriticalSection,0> & channelList) Line 2914	C++
 	FSynth.vst3!juce::JuceVST3Component::process(Steinberg::Vst::ProcessData & data) Line 2732	C++
 	[External Code]	

I figured out what was causing it. Loading a new plugin caused a refresh of the editor, which reset the app at the same time. The fix was to move the setting out of the editor and into something ultimately owned by the processor.

Acquiring the MessageManagerLock from processBlock is almost certainly a bug. I’d recommend looking for ways to remove this lock.

I think the bug you’re seeing, at least in the AudioPluginHost, is that the audio thread will lock the AudioProcessorGraph’s callback lock, and then the message manager. Meanwhile, when a new plugin is added, the plugin will be created on the main thread (with the message manager locked), and then the callback lock is taken when the plugin is added to the graph. Taking the locks in different orders from different threads results in a hierarchical deadlock.

1 Like

Very informative. So, the MessageManagerLock locks the message manager for the entire host and all plugins in it.