From cb07fd07a26d7c0450e0b04b4346a246c855e5ee Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 29 Apr 2021 23:09:20 +0200 Subject: [PATCH] Handle mutual recursion while loading presets --- CHANGELOG.md | 2 ++ src/wine-host/bridges/vst3.cpp | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e16c3c5d..c101b248 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). - Fixed the VST3 version of _W. A. Production ImPerfect_ from crashing during audio setup. - Fixed _UVI Plugsound Free_ crashing during initialization. +- Fixed a rare potential freeze when loading a VST3 plugin preset while the + plugin is being resized. - Because of the new transport information prefetching, the excessive DSP usage in _SWAM Cello_ is now been fixed without requiring any manual compatibility options. diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index 22434a97..3f10f661 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -234,20 +234,20 @@ void Vst3Bridge::run() { -> Vst3PluginProxy::SetState::Response { // We need to run `getState()` from the main thread, so we might // as well do the same thing with `setState()`. See below. - return main_context - .run_in_context([&]() { - // This same function is defined in both `IComponent` - // and `IEditController`, so the host is calling one or - // the other - if (object_instances[request.instance_id].component) { - return object_instances[request.instance_id] - .component->setState(&request.state); - } else { - return object_instances[request.instance_id] - .edit_controller->setState(&request.state); - } - }) - .get(); + // NOTE: We also try to handle mutual recursion here, in case + // this happens during a resize + return do_mutual_recursion_on_gui_thread([&]() { + // This same function is defined in both `IComponent` and + // `IEditController`, so the host is calling one or the + // other + if (object_instances[request.instance_id].component) { + return object_instances[request.instance_id] + .component->setState(&request.state); + } else { + return object_instances[request.instance_id] + .edit_controller->setState(&request.state); + } + }); }, [&](Vst3PluginProxy::GetState& request) -> Vst3PluginProxy::GetState::Response {