Resizing plugins in Logic is jerky

When you resize a plugin created with JUCE > 6.1.2 in Logic, the resizing is jerky, see this video.

Although you enlarge the GUI size by dragging the resizer triangle, the current values for width and height in PluginEditor::resized() are occasionally smaller(!) than the ones in the previous call. This leads to unsightly jumps in the editor size during resizing.

I checked this with both JUCE 7.0.5 and the current develop branch.

The problem occurs for example in Logic 10.7.7 on Ventura/M1 and in Logic 10.6.3 on Catalina (Intel).

To reproduce this, I created a basic plugin “ResizablePlugin” (https://github.com/CppClown/ResizablePlugin.git) with the Projucer and did the following modifications:

  1. PluginEditor.h: Add private members mWidth and mHeight and a text editor:
...
private:
    // This reference is provided as a quick way for your editor to
    // access the processor object that created it.
    ResizablePluginAudioProcessor& audioProcessor;

    int mWidth { 0 };
    int mHeight { 0 };
    juce::TextEditor mTextEditor;
...
  1. PluginEditor.cpp: The text editor is added in the constructor. Likewise, the code to allow resizing is added:
...
ResizablePluginAudioProcessorEditor::ResizablePluginAudioProcessorEditor (ResizablePluginAudioProcessor& p)
    : AudioProcessorEditor (&p), audioProcessor (p)
{
    //-------- Text editor.

    mTextEditor.setReadOnly(true);
    mTextEditor.setFont(Font("Consolas", 16.f, Font::FontStyleFlags::plain));
    mTextEditor.setMultiLine(true);
    addAndMakeVisible(mTextEditor);
    
    //-------- Set size and limits.
   
    const auto minWidth = 500.f;
    const auto minHeight = 375.f;
    const auto maxWidth = 1240.f;
    const auto maxHeight = 930.f;
    
    setResizable(false, true);
    
    if (auto componentBoundsConstrainer = getConstrainer())
    {
        componentBoundsConstrainer->setSizeLimits(
            roundToInt(minWidth), roundToInt(minHeight),
            roundToInt(maxWidth), roundToInt(maxHeight));

        componentBoundsConstrainer->setFixedAspectRatio(4.f / 3.f);
    }
    
    setSize(minWidth, minHeight);
}
...
  1. PluginEditor.cpp: Add code to resized() to display the current width and height. Each time the size is smaller than the previous size, a message is issued.
...
void ResizablePluginAudioProcessorEditor::resized()
{
    // This is generally where you'll want to lay out the positions of any
    // subcomponents in your editor..
    
    mTextEditor.setBounds(getLocalBounds());
    
    const auto w = getWidth();
    const auto h = getHeight();

    mTextEditor.insertTextAtCaret("w = " + String(w) + ", h = " + String(h));
    
    if (w < mWidth || h < mHeight)
    {
        mTextEditor.insertTextAtCaret(" Smaller than previous size!");
    }
    
    mTextEditor.insertTextAtCaret("\n");
        
    mWidth = w;
    mHeight = h;
}
...

Now when you run the plugin in Logic and enlarge its GUI by dragging the resizer triangle, the message “Smaller than previous size!” is occasionally output. It is especially annoying when you move the mouse quickly, because then the jumps are large. This should not happen.

Obviously the problem was introduced in commit https://github.com/juce-framework/JUCE/commit/4ca923a34b3cec79b50c3f1cb794f8327d7530a0.

Could you please take a look and possibly offer a solution? Thank you very much.

3 Likes

Thanks for providing a demo project. That makes it much easier to reproduce issues and track down problems.

It looks like this particular problem could be caused by the mouse entering and exiting the plugin editor during the resize, generating conflicting mouse events.

The following patch seems to resolve the issue for me; could you try it out and let me know if the problem goes away for you? Thanks!

tracking.patch (1.4 KB)

2 Likes

Many thanks for the quick reply and providing a solution.

I can confirm that the problem is fixed with your patch. Resizing in Logic now works like a dream. I have tested both Logic 10.7.7 on Ventura/M1 and Logic 10.6.3 on Catalina (Intel). I also did some quick testing on Catalina in Cubase 12.0.40 (VST3), Ableton 11.2.10 (VST3, AU) and Studio One 5.5.2 (VST3, AU). Nothing seems to be broken.

Thanks again!

@reuk Will the patch be added to the development branch in the foreseeable future?

Yes, but it needs to be reviewed first. I expect it’ll be public in the next week or two.

1 Like

Perfect. Thank you!

Thanks for your patience, this is merged now:

2 Likes