From 9f3fba69880f6023540daa65b1527009be41e4c4 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 11 Mar 2021 18:19:21 +0100 Subject: [PATCH] VST3: Prevent recursive endless resizing Skip call to onSize() when the plugin's size already matches. https://github.com/Ardour/ardour/pull/599 https://github.com/juce-framework/JUCE/pull/867 https://discourse.ardour.org/t/sonobus-vst3-gui-hogs-cpu-only-when-ran-inside-ardour-on-linux-but-not-windows/105573 --- gtk2_ardour/vst3_hwnd_plugin_ui.cc | 4 +++- gtk2_ardour/vst3_nsview_plugin_ui.mm | 4 +++- gtk2_ardour/vst3_x11_plugin_ui.cc | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/vst3_hwnd_plugin_ui.cc b/gtk2_ardour/vst3_hwnd_plugin_ui.cc index a9841ab5ab..ab7868e8f7 100644 --- a/gtk2_ardour/vst3_hwnd_plugin_ui.cc +++ b/gtk2_ardour/vst3_hwnd_plugin_ui.cc @@ -94,7 +94,9 @@ VST3HWNDPluginUI::view_size_allocate (Gtk::Allocation& allocation) } PBD::Unwinder uw (_resize_in_progress, true); ViewRect rect; - if (view->getSize (&rect) == kResultOk) { + if (view->getSize (&rect) == kResultOk + && ! (rect.right - rect.left == allocation.get_width () && rect.bottom - rect.top == allocation.get_height ())) + { rect.right = rect.left + allocation.get_width (); rect.bottom = rect.top + allocation.get_height (); #if 0 diff --git a/gtk2_ardour/vst3_nsview_plugin_ui.mm b/gtk2_ardour/vst3_nsview_plugin_ui.mm index 4c685e8005..b5b665ba09 100644 --- a/gtk2_ardour/vst3_nsview_plugin_ui.mm +++ b/gtk2_ardour/vst3_nsview_plugin_ui.mm @@ -122,7 +122,9 @@ VST3NSViewPluginUI::view_size_allocate (Gtk::Allocation& allocation) PBD::Unwinder uw (_resize_in_progress, true); ViewRect rect; - if (view->getSize (&rect) == kResultOk) { + if (view->getSize (&rect) == kResultOk + && !(rect.right - rect.left == allocation.get_width () && rect.bottom - rect.top == allocation.get_height () && rect.left == xx && rect.top == yy)) + { rect.left = xx; rect.top = yy; rect.right = rect.left + allocation.get_width (); diff --git a/gtk2_ardour/vst3_x11_plugin_ui.cc b/gtk2_ardour/vst3_x11_plugin_ui.cc index c7a20b9ec3..3dbc611100 100644 --- a/gtk2_ardour/vst3_x11_plugin_ui.cc +++ b/gtk2_ardour/vst3_x11_plugin_ui.cc @@ -247,7 +247,9 @@ VST3X11PluginUI::view_size_allocate (Gtk::Allocation& allocation) PBD::Unwinder uw (_resize_in_progress, true); ViewRect rect; - if (view->getSize (&rect) == kResultOk) { + if (view->getSize (&rect) == kResultOk + && ! (rect.right - rect.left == allocation.get_width () && rect.bottom - rect.top == allocation.get_height ())) + { rect.right = rect.left + allocation.get_width (); rect.bottom = rect.top + allocation.get_height (); #if 0