Linux VST3 plugin with OpenGL crashing when editor is reopened

I have a component like this:

#pragma once
#include <juce_gui_basics/juce_gui_basics.h>
#include <juce_opengl/juce_opengl.h>

using namespace juce;

class OpenGLComponent : public Component, public OpenGLRenderer
{
    public:
        OpenGLComponent();
        ~OpenGLComponent() override;

        void paint (Graphics&) override {}
        void resized() override {}

        void newOpenGLContextCreated() override;
        void renderOpenGL() override;
        void openGLContextClosing() override;

    private:
        OpenGLContext openGLContext;

        JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLComponent)
};

and

#include "OpenGLComponent.h"

OpenGLComponent::OpenGLComponent()
{
    openGLContext.setRenderer (this);
    openGLContext.attachTo (*this);
}

OpenGLComponent::~OpenGLComponent()
{
    openGLContext.detach();
}

void OpenGLComponent::newOpenGLContextCreated() {}

void OpenGLComponent::renderOpenGL() {}

void OpenGLComponent::openGLContextClosing() {}

and when I use it in a plugin’s editor on Linux, the host crashes the second time I open the editor. Before the crash I get these errors:

ERROR: X returned BadWindow (invalid Window parameter) for operation X_UnmapWindow
ERROR: X returned BadWindow (invalid Window parameter) for operation X_DestroyWindow

I’ve made a repository on github with the simplest example I could write that triggers the crash:

Since the example on JUCE’s website is an application (https://docs.juce.com/master/tutorial_open_gl_application.html) I’m wondering if there’s anything I should be doing differently in a VST or if this is really a bug.

Any suggestions?

Thanks for reporting. This has now been fixed on the develop branch with these commits:

1 Like