Crash On OpenGL Plugin Close (repeatable in Plugin Host)

Still having serious problems with plugin with an OpenGL UI. Now the crash is triggered on closing the plugin window repeatable in Plugin Host and intermittently in Ableton Live. It asserts at the end of:

OpenGLContext::copyTexture

It only happens with openGLContext.setContinuousRepainting (true);

I stripped away almost everything from my project leaving a plugin declared as
class ScrollingNoteViewer: public Component, private OpenGLContext, private OpenGLRenderer

It paints nothing, does no GL initialization and renders nothing, it still crashes the same way.

Here is the header file:

#ifndef __JUCE_HEADER_B11C4CC4490D982E__
#define __JUCE_HEADER_B11C4CC4490D982E__

#include "../JuceLibraryCode/JuceHeader.h"
#include "PluginProcessor.h"
#include <array>
class ScrollingNoteViewer  :    public Component, private OpenGLContext, private OpenGLRenderer
{
public:
    ScrollingNoteViewer (ReExpressorAudioProcessor*);
    ~ScrollingNoteViewer();
    
    virtual void mouseDown (const MouseEvent& event) override;
    virtual void mouseUp (const MouseEvent& event) override;
    virtual void mouseDoubleClick (const MouseEvent& event) override;
    virtual void mouseDrag (const MouseEvent& event) override;
    virtual void mouseWheelMove (const MouseEvent& event,
                                 const MouseWheelDetails& wheel) override;
    virtual void mouseMagnify (const MouseEvent& event, float scaleFactor) override;
    
    OpenGLContext openGLContext;
    virtual void newOpenGLContextCreated() override;
    virtual void renderOpenGL() override;
    virtual void openGLContextClosing() override;
    
    void paint (Graphics& g) override;
    void resized() override;
    
private:
    ReExpressorAudioProcessor *processor;
    
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ScrollingNoteViewer)
};

//[EndFile] You can add extra defines here...
//[/EndFile]

#endif   // __JUCE_HEADER_B11C4CC4490D982E__

Here is the cpp file:

#include "ScrollingNoteViewer.h"
#include <array>

ScrollingNoteViewer::ScrollingNoteViewer (ReExpressorAudioProcessor* p) :processor(p)
{
    openGLContext.setMultisamplingEnabled(true);
    OpenGLPixelFormat format;
    format.multisamplingLevel = 4;
    openGLContext.setPixelFormat(format);
    setPaintingIsUnclipped(true);
    openGLContext.setRenderer (this);
    openGLContext.attachTo (*this);
    openGLContext.setContinuousRepainting (true);
}

ScrollingNoteViewer::~ScrollingNoteViewer()
{
}
void ScrollingNoteViewer::mouseDown(const MouseEvent &e)
{
}
void ScrollingNoteViewer::mouseUp (const MouseEvent& event)
{
}
void ScrollingNoteViewer::mouseDoubleClick (const MouseEvent& event)
{
}
void ScrollingNoteViewer::mouseDrag (const MouseEvent& event)
{
}
void ScrollingNoteViewer::mouseWheelMove (const MouseEvent& event, const MouseWheelDetails& wheel)
{
}
void ScrollingNoteViewer::mouseMagnify (const MouseEvent& event, float scaleFactor)
{
}

//initialise
void ScrollingNoteViewer::newOpenGLContextCreated()
{
}
//render
void ScrollingNoteViewer::renderOpenGL()
{
}
//shutdown openGL
void ScrollingNoteViewer::openGLContextClosing()
{
}
void ScrollingNoteViewer::paint (Graphics& g)
{
}
void ScrollingNoteViewer::resized()
{
}

//==============================================================================
#if 0
/*  -- Projucer information section --
 
 This is where the Projucer stores the metadata that describe this GUI layout, so
 make changes in here at your peril!
 
 BEGIN_JUCER_METADATA
 
 <JUCER_COMPONENT documentType="Component" className="ScrollingNoteViewer" componentName=""
 parentClasses="public Component" constructorParams="" variableInitialisers=""
 snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
 fixedSize="0" initialWidth="600" initialHeight="400">
 <BACKGROUND backgroundColour="ffffffff"/>
 </JUCER_COMPONENT>
 
 END_JUCER_METADATA
 */
#endif
//[EndFile] You can add extra defines here...
//[/EndFile]

I can send you a complete zip file of the project. I couldn’t see how I could attach a zip file to this post.

This is on OSX 10.11.5

Try detaching from the openGLContext in the destructor ~ScrollingNoteViewer.

Thanks. I added:

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

Unfortunately it still asserts the same way on closing the plugin window.

Note that if I run the plugin outside the debugger doesn’t crash but I’m not sure if it’s safe to ignore the assert.