From 70a546d160603f530730c31981726480accafc65 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 15 May 2021 23:47:07 +0200 Subject: [PATCH] Handle setting channel infos as mutually recursive This was causing a timing issue with DMG plugins where the plugins would try to resize after receiving new state (and not during the call), while REAPER at the same time would try to set channel context information on the plugin (which also has to be handled on the GUI thread). --- CHANGELOG.md | 2 ++ src/plugin/bridges/vst3-impls/plugin-proxy.cpp | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a58dcc05..29d69e2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed +- Prevent _DMG_ VST3 plugins from freezing in **REAPER** under certain + circumstances. - Fixed builds on Wine 6.8 because of internal changes to Wine's `windows.h` implementation. diff --git a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp index 24f1c08b..d5b1650c 100644 --- a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp +++ b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp @@ -836,9 +836,17 @@ Vst3PluginProxyImpl::endEditFromHost(Steinberg::Vst::ParamID paramID) { tresult PLUGIN_API Vst3PluginProxyImpl::setChannelContextInfos( Steinberg::Vst::IAttributeList* list) { if (list) { - return bridge.send_message(YaInfoListener::SetChannelContextInfos{ - .instance_id = instance_id(), - .list = YaAttributeList::read_channel_context(list)}); + // NOTE: After getting and setting state, the plugin may want to resize + // to match its old size. The DMG plugins tend to delay this + // request until after the state has been set, but at that point + // in time REAPER will also send channel context info. Both of + // these things need to be handled on the GUI thread on their + // receiving sides, resulting in a deadlock without this mutual + // recursion. + return maybe_send_mutually_recursive_message( + YaInfoListener::SetChannelContextInfos{ + .instance_id = instance_id(), + .list = YaAttributeList::read_channel_context(list)}); } else { bridge.logger.log( "WARNING: Null pointer passed to "