JUCE 6.0.1 OpenGL Issue

Dear JUCE developers,

I have just updated to JUCE 6.0.1 from JUCE 5.4.5 and found that the OpenGL component has different behavior, and I had to downgrade the latest OpenGL module to the one of version 5.4.5.

I am using OpenGL to convert juce::Component to heavy-weight component so that I can use other heavy-weight components such as VideoComponent, OpenGLComponent, and WebComponent at the same level, and control their Z-orders each other (bringing a component above the other component and so on).

With the version 5.4.5, I was handling the Z-order of each heavy-weight component by the following code.

void bringToFrontObj(juce::Component* owner)
    //get NSOpenGLContext
    NSOpenGLContext* context = (NSOpenGLContext*)this->ctx.getRawContext();
    // if failed, then return
    if(context == nullptr) return;
    // get Peer
    auto* peer = owner->getPeer();
    if(peer != nullptr)
        // bring the view to the front of all other view
        auto peerView = (NSView*) peer->getNativeHandle();
        [context.view retain];
        [context.view removeFromSuperview];
        [peerView addSubview: context.view];
        [context.view release];

    [context.view setHidden: ! owner->isShowing()];

Now, JUCE 6 has strange blinkings every time when changing the Z-Order of each component by the above code while JUCE 5.4.5 doesn’t.
Please watch the attached video on Youtube where the left shows the behavior of JUCE 5.4.5 and the right is the one of JUCE 6.0.1.

Go to Youtube Video

I am just bringing a square object to front or back to the VideoComponent by changing the Z-order in order to create show/hide effect.
The reason to change the Z-Order to show/hide the square object is that it does not invoke “detach” OpenGLContext in the version 5.4.5 and could prevent blinking effects.
But now, in JUCE 6.0.1, we can see the blinking effects as if the detach method is called.

I would be super delighted if you could check the OpenGL modules and let me know any solutions.
Thank you very much for your support.