White flash for the first OpenGL frame only in Logic Pro

My audio plugin needs to create several textures for the background images and render the OpenGL context, I have already tried many ways to optimize my code, and initialize the texture image before attaching the OpenGL context, but still in Logic Pro, when clicked on the plugin in, after the UI shows up, sometimes there is a white flash. In other DAWs such as Cubase 9.5, Live, no white flash.

Anyone have idea?

[In Adobe Audition, there is white flash every time I start the UI]

1 Like

I had this issue, I approached it with a small workaround. My recollection of events is a bit hazy but I think it only happened when I added the GL context to the top level editor window or a child that was the same size as the main window. So I made the main window 1 pixel wider and taller than I actually wanted, added everything to a very trivial component the size I did want, then added that component to the main window. I added the GL context to the container child window. I also made sure all paint overrides for the main and the slight-smaller window were filling with black (my plugin background was black). Then I got a black flash rather than a white flash, which was much less bothersome. Not a solution, but acceptable enough to move on for me at the time.

2 Likes

@hill_matthew
Wow, amazing, your solution works, now it still flashes, but it is not very apparent as before, I wonder how did you come up with this solution, and which party is to be blamed? JUCE or DAW?

Honestly I am a bit perfectionist, so I really want to find out the root cause of this problem and solve it.

Thank you for sharing your experience, XD

1 Like

This is happening to me as well, also in standalone apps.
I’m on a 27" iMac (5K resolution). It seems to work ok on other iMacs (21").
@fabian Can you reproduce this?
My current workaround is to attach the OpenGLRenderer after 1 second using a Timer.
Cheers!

Sorry, do you mean attach GL context to the component 1 second after the component is created? this solution doesn’t work for me.

I am using Mac book pro.

I wonder how did you come up with this solution

I observed that adding the context to other components deeper in the component hierarchy wasn’t causing the problem, so just trial and error experimentation from there.

Honestly I am a bit perfectionist, so I really want to find out the root cause of this problem and solve it.

Yes me too!

Yeah that’s what I meant.

Hmmm can’t really reproduce this. Does this have to do with the complexity of the OpenGL scene/quantity of gl resources? If yes, could you render something simple in the first few render callbacks and then start loading resources (on the gl thread) in the next couple of render callbacks?

Hi

I’ve created an example video to illustrate it:

This is simply a default Juce plugin project with an OpenGLContext defined as a private member in the UI’s header:

juce::OpenGLContext ctx;

This is used in the of the constructor as follows:

ctx.attachTo(*this);

It’s the same if I do this before or after the UI constructor’s setSize call.

Matt

Yep, I’m doing the same as @hill_matthew, the only difference is that I’m doing it in the MainWindow class since in my case it’s a standalone app.

In my point of view, this problem is not related to OpenGL scene/quantity, because my code works fine on Cubase/Pro Tools/Live, it has white flash only on Logic Pro DAW.

I find it’s a bit more widespread, this happens in Cubase 9.5 (9.5.30), Reaper (5.91), Live (9) and Logic X (10.4.1) with the simple test I produced, both VST and AU where applicable. It affects multiple Macs of differing ages too.

OK I understand now. I was using the teapot demo (as a plug-in) to reproduce. I can reproduce this by simply using the OpenGL as the rendering engine.

This is due to JUCE using OpenGL overlay views when doing OpenGL. Also, you can only start rendering into the view after it’s been put on the screen (i.e. is visible) - hence you see the brief empty OpenGL view.

I’ll try to come up with a workaround…

2 Likes

I wonder if this has to do with not using CVDisplayLink. In SurferEQ2 the EQ curve is drawn using OpenGL and here in Logic X it simply takes a split-second before the curve appears but there are no flashes.

If someone wants to check you can try a build using SR’s JUCE branches (master is for JUCE 4, and juce5 for JUCE 5) which do use CVDisplayLink for OpenGL on macOS.

That’s odd. When building from your branch, the white flash is much more pronounced on my machine.

True, my colleague just showed me that this is indeed the case with some of our other plugins which attach an OpenGL context to the top-level component (because there we found the UI was snappier with OpenGL).

But in the one where only a sub-component uses OpenGL there’s no flash.

Yes, but that’s the same with our branch.

Hi Fabian! Is there an update on this?

1 Like

Just adding, since I started using it on my analyser, it also flashes, if you resize the pluginEditor…
That way it is easier to trigger, if that helps…

1 Like

Any news?