MessageManagerLock caused crash on Ableton Live 11.3.2

Hi, I have a background thread starting at the end of constructor of PluginEditor to check for activation and update. There will be some UI work inside so I put a MessageManagerLock to avoid assert. However, this will crash Ableton Live 11.3.2 though such a thing never happens to standalone and other DAWs. So this could be a Ableton Live bug itself.

My current workaround is to remove the MessageManagerLock although I understand it is dangerous which may result in other problems. Should JUCE team takes a look or just wait for Ableton to resolve this?

Is it a real crash, or does your plugin just hang? Also is this specific to VST3 or does the same happen in VST2 as well?

This might be related:

Hi, it crashes Ableton completely. As I said this only happens in Ableton and Cubase 12 could run it without any problem. I only tested on VST3 since VST2 is deprecated. I read the post and it seems the latest JUCE has some issues related to MessageManagerLock too. The JUCE version I use is v7.0.5 and the build date is Jan 28 2023. Seems already the latest one.

I’m also having very mixed experiences with MessageManagerLock while hosting AU units like Kontakt and Keyscape!

Here I have a method to wrap a std::function onto the message thread without using MessageManagerLock:

template <typename Result, typename Argument>
std::function<Result(Argument&&)> onMessageThread(std::function<Result(Argument&&)> func)
  /* if (AmIBeingTested()) return func; */
  return [func = std::move(func)](Argument&& arg) {
    if (juce::MessageManager::existsAndIsLockedByCurrentThread()) // avoid dead locks when calling performNow
    juce::WaitableEvent event;
    Result result;
    juce::MessageManager::callAsync([&result, &arg, &func, &event]() {
      result = std::move(func(std::move(arg)));
    return result;

My tip: never use the MML in a plug-in. As a plug-in you’re not in full control of the message-thread, which can lead to all kind of dead-lock situations. Better use asynchronies, non blocking, operations instead.

1 Like

I used MessageManager::callAsync before and the result was the same.

You don’t always have that luxury. Certain things can only be executed on the MessageThread, or you have to prevent the MessageManager from executing; even if your algorithm only takes a very short amount of time, the MessageManager mustn’t do anything in between.

If you never had that problem, great for you. That doesn’t mean other people don’t encounter it.

Have you tried with previous versions of Ableton Live? Does it happen with them as well or is that behavior specific to 11.3.2?

Your issue might be related to the changes that were made in Ableton Live to address some performance issues. See JUCE plugins cause poor DAW UI performance on Windows? - #38 by JFelliz

Yes. I did tried with the Ableton Live Trial which is not the latest version and everything was ok. Seems they made some fixes but inflicted other problems.