OpenGLHelpers::isContextActive() crashes in ProTools

Hey guys -

Fairly easy to reproduce crash here, if you add:

if (OpenGLHelpers::isContextActive()) OpenGLHelpers::clear(Colours::grey);

To the resize method of you pluginEditor, you get some serious issues in ProTools and PluginDoctor.

Specifically, if the plugin is has an active gl context, you get a crash in either program.

If the plugin does not have a context, then PT is fine and PluginDoctor hangs (PT doesn’t use gl for rendering, PluginDoctor does … which seems to be the difference).

I assume this call should be valid when called from resize(), but please let me know if not.

I am making this call simply to clear the context (since otherwise it is bright RED, which is ugly):

An OpenGL context is not thread-safe. This means that if you try to modify the context (e.g. by clearing it) from a thread other than the rendering thread, you’ll run into problems. I’d recommend only attempting to modify the OpenGL context from within Component::paint or OpenGLRenderer::renderOpenGL.

1 Like

Aha! Good to know, I was wondering if that might be the case.

Follow up then: could we please have new contexts clear to something other than RED? When resizing a plugin that uses openGL, it’s quite ugly to get flashes of red around the edges.

2 Likes

I agree with Aaron. It would be great to somehow set the color, but at the very least don’t be red. Black (preferred for me) or white would be much better, and not freak out users.

1 Like