3rd party AudioProcessorEditor not behaving like a normal Component

I’m working on a plugin host, and I’m trying to embed plugin GUIs inside one of my canvas components. (In my app, the plugin GUIs don’t have their own windows, they share the canvas with other windows).

The embedding is working, and I can see and interact with the plugin GUI, but when I try to resize it and especially when I zoom around the canvas, it starts behaving erratically. It won’t stick to its bounds, and most tellingly, it won’t disappear if I do removeChildComponent().

To test it, I’m running this code:

class EditorTester : public juce::Timer

    EditorTester(juce::Component& par, std::unique_ptr<juce::Component> ch)
    :  parent(par), child(std::move(ch)) { startTimer(1000); }

    void timerCallback() override
        if (b)

        b = !b;


    bool b = false;
    juce::Component& parent;
    std::unique_ptr<juce::Component> child;

void MyComponent::initialize()
    auto b = new EditorTester(*this, pluginInterface->getEditor());  // memory leak, just for testing

In this code, the editor appears when the timer adds it the first time, but then never disappears.

Can anyone advise me with this?

I’m thinking loud here… Could it be you have to destroy the child, not just make it an orphan? Or if that sounds to cruel, make it invisble, setVisble(false) ?

After all, also orphans can have a life…

Good call. setVisible() doesn’t work, but deleting and then recreating the plugin does. I guess I could go that route, but it seems a bit heavy handed. It seems like if the component isn’t removing correctly that something’s going wrong somewhere. Has anyone run into this issue before?

One more thing: When I scroll the canvas using the viewport, the GUI component doesn’t scroll with it but stays where it originally was. In short, the whole thing seems to be behaving as if the paint engine doesn’t know that the GUI component is there.

Is this a bug in my code or in juce code? I’m not doing anything fancy, just addAndMakeVisible(pluginGui), so I’m failing to see where I could be going wrong.

Edit: It’s the VST3PluginWindow that I’m dealing with here.

And you haven’t forgotten to use setViewedComponent() instead of addAndMakeVisible() when using Viewport? :thinking:

I’ve called setViewedComponent() on the canvas, not on the editor GUI. The editor GUI belongs to the canvas.

Here is a clip of what I’m talking about.

Untitled ‑ Made with FlexClip (2)

Obviously there are some more complicated things going on here with affine transformations and Component wrappers, but when I’ve tried doing something simple (like in the test code above) I still get the same result, suggesting that it’s not a problem with my code.

I’m doing something similar with my plugin host, only I’m using Tracktion and the ExtendedUIBehaviour method to get plugin windows embedded, since my host is intended for loading tracktionEdit files … perhaps there are clues for you in the tracktion_UIBehaviour.h header? To my eyes your situation looks like a missing child/parent relationship (binding) in the Component hierarchy, meaning scroll/resize events aren’t propagating to your plugins’ component …

I took a look through those files on GitHub, but i couldn’t find much that relates to the AudioPluginEditoer class.

I agree that it looks like a problem with the hierarchy, but i can’t see what I’m doing wrong. If it were a normal Component, it would be behaving normally.