OpenGLTexture::release() Assert

I have a very simple app that is displaying an image in an OpenGLRenderer object. I get an assert on destroying the component and was hoping someone could tell me what I was doing wrong.
The assertion is in JUCE Assertion failure in opengl/juce_OpenGLTexture.cpp:164.

This is the class which will cause an assertion when deleting this component

class OGLTestComponent : public OpenGLRenderer, public Component

	OGLTestComponent() {

	~OGLTestComponent() {
	virtual void paint(Graphics& g) {


	virtual void newOpenGLContextCreated() {
		img = Image(Image::PixelFormat::ARGB, getBounds().getWidth(), getBounds().getHeight(), true);

	virtual void renderOpenGL()
		// Create an OpenGLGraphicsContext that will draw into this GL window..
		ScopedPointer<LowLevelGraphicsContext> glRenderer(createOpenGLGraphicsContext(context, getWidth(), getHeight()));

		if (glRenderer != nullptr)
			if (img.isValid())
				Graphics g(*glRenderer);
				g.drawImage(img, getLocalBounds().toFloat());

	virtual void openGLContextClosing() {
		img = Image::null;

	Image img;
	OpenGLContext context;

Do you have the same assert if you remove the image in the destructor instead of the OpenGL ContextClosing ? Do you even need to remove the image manually since it is deleted automatically with the class ?

Your code looks fine to me. I’ve just copy&pasted your code and run it on a mac and I don’t get the assertion you are talking about. Which platform is this occurring on? Are you using the master or the develop branch?

This is on windows in a VST3 Plugin, a child component of the editor. this assert fires when closing the editor.

I’m seeing the same assertion on Windows AAX. I am currently on the develop branch, but last pulled 3/17/2017.

Still seeing this using the tip of the develop branch. Windows only. Occurs in plug-ins that use OpenGL and images. I’ve attached a very simple PIP that demonstrates the issue.

Steps to reproduce:

  • Load the plug-in.
  • Open its GUI.
  • Click the button name “push”. This will start an animation that uses a proxy, internally creating an image.
  • Close the GUI.

OpenGLTextureAssertionExample.h (5.4 KB)

1 Like

Thanks @ed95

Can this be done for AAX too please?
Pull request here if it helps.

This should work for both:

1 Like

Great! Thanks again.