Glitch in OpenGL during resize

Hi,

We are experiencing glitches in our OpenGL-based application on Windows. The entire UI freezes when resizing the application. The window remains resizable, but newly resized areas turn black. This is a serious problem for our application and occurs frequently, though randomly, sometimes after a few seconds, other times only after several minutes.

We created a JUCE demo project (code below) that reproduces the glitch (screenshot below). To reproduce it, launch the app and resize it a few times. If the glitch does not appear, relaunch the app and try again. It may take up to 30 minutes to trigger.

We have tested this with JUCE 8.0.10. The issue occurs only on Windows.

struct MainComponent : juce::Component
{
    MainComponent()
    {
        setSize(1280, 768);
    }

    struct OpenGLRenderer : juce::OpenGLRenderer
    {
        juce::OpenGLContext context;

        OpenGLRenderer(juce::Component& attachTo)
        {
            context.setOpenGLVersionRequired(juce::OpenGLContext::openGL3_2);
            context.setRenderer(this);
            context.setContinuousRepainting(true);
            context.attachTo(attachTo);
        }

        ~OpenGLRenderer() override
        {
            context.detach();
        }

        void newOpenGLContextCreated() override {}

        void renderOpenGL() override
        {
            juce::OpenGLHelpers::clear(juce::Colours::green);

            juce::gl::glEnable(juce::gl::GL_SCISSOR_TEST);
            juce::gl::glScissor(0, 0, 500, 500);
            juce::OpenGLHelpers::clear(juce::Colours::blue);
            juce::gl::glDisable(juce::gl::GL_SCISSOR_TEST);
        }

        void openGLContextClosing() override {}
    };

    OpenGLRenderer openGLRenderer{ *this };
};

Best,

Jelle

Has this post been noted by the JUCE team?

@jellebakker thanks for reporting the issue. Sorry we haven’t responded sooner. We have seen this but there are a few things on a plates right now. We will take a look at this as soon as possible. In the meantime if you find a way to improve the re-producibility of this issue that would be extremely helpful as something that potentially takes 30 minutes to trigger is going to be very hard and time consuming both to reproduce but also confirm it’s fixed!

If you do find a better way to reproduce it, it could also be helpful to try performing a git bisect to see if it’s possible to detect when the issue was introduced.

We incrementally tested older versions of JUCE to find where the bug was introduced but found that the bug exists for all tested versions, back to 7.0.0.

We’d like to emphasize that we have already spent many days investigating this issue. Unfortunately, it is still hard to reproduce in this simple example but for our application it occurs perhaps as much as one in three times.

The most reliable replication of the bug in our application seems to be resizing immediately after launching, though the bug may occur when resizing any time in the application’s lifetime.

The video below shows the bug occuring for our application after the second launch.

Our application is open-source and so is available for anyone to test. We’re open to all suggestions, including working with JUCE to help solve this.