ComboBox Issue: AUv3 Plugin Crashes in Garageband & Logic

So I’m facing a strange issue. I’m working on a Synth plugin. In Garageband and Logic, whenever I add a ComboBox, my plugin crashes. Specifically, the UI loads and looks great, the controls all work fine, except for the ComboBox. As soon as a user clicks on the ComboBox, the plugin UI goes white and stops producing sound. This only happens in Garageband and Logic.

To simplify debugging, I tried boiling things down to the simplest possible version of my plugin: I made a completely vanilla JUCE plugin project, I added a ComboBox to its editor, and I made an AUv3 out of it. Lo and behold, the test plugin crashed as well. I debugged Garageband so that I could get a trace on the crash. This is what it produced:

It’s hard to see from my screenshot, but the specific error is EXC_BAD_INSTRUCTION.

So…is this a bug in ComboBox or am I doing something wrong?

i’ve seen the same behavior in the same hosts for other components too - you have to explicitly make the new window owned by your current editor window (rather than let it be a new window on the desktop - note the crash triggers from a call to removeFromDesktop).

Ah, is there a way of doing that without subclassing ComboBox?

Quick forum search revealed this: PopupMenu not showing on AUv3 plugin
Haven’t tested it myself

it doesn’t look like i have a workaround for PopupMenu - it seems to be just working. can you make sure none of your other code is calling addToDesktop?

No, nothing like that. The only changes I made to the vanilla JUCE project is declaring the variable in the editor’s .h file:

ComboBox osc1TypeComboBox;

Adding the ComboBox in the constructor to the editor:

osc1TypeComboBox.addItem("Sine", 1);    
osc1TypeComboBox.addItem("Saw", 2);    
osc1TypeComboBox.addItem("Sqr", 3);

And positioning it in the resized() function:

osc1TypeComboBox.setBounds(10, 10, 100, 30);

I’m going to give the LookAndFeel method hacking a try.

So the LookAndFeel method works!

For anyone who runs into this issue, here’s what I added to my editor .h file:

class ForcePopupsInParentWindow : public LookAndFeel_V4
         Component* getParentComponentForMenuOptions (const PopupMenu::Options& options) override
        #if JUCE_IOS || JUCE_MAC
            if (PluginHostType::getPluginLoadedAs() == AudioProcessor::wrapperType_AudioUnitv3)
                 if (options.getParentComponent() == nullptr && options.getTargetComponent() != nullptr)
                     return options.getTargetComponent()->getTopLevelComponent();
           return LookAndFeel_V4::getParentComponentForMenuOptions (options);
    ForcePopupsInParentWindow lf;

I also added this to the top of my constructor:

setLookAndFeel (&lf);

and I added this to my destructor:

setLookAndFeel (nullptr);

Needless to say, if you’re already using your own LookAndFeel, you can just modify that. I’m not sure why all of this was necessary, but there you have it. :slight_smile:

Thanks @danielrudrich and @modosc for pointing me in the right direction!