Juce OpenGL crash when window loses focus

Hi all,

We have a plugin for Photoshop built using Juce. When user adds the plugin to photoshop layer, our juce window pops'up. This window is using OpenGL component. It is crashing randomly when the Juce window loses focus.

We built the jcue demo as a dynamic library and loaded that instead of our own window in our plugin. All other demo's except OpenGL demo works fine.  But, OpenGL demo crashes in Draw->SwapBuffer.

Note that it works perfectly fine on Windows.

I was wondering if anyone else have faced similar issues on MAC.



Do you mean that it crashes when the window loses focus and stays on screen, or does loss of focus actually cause the window to be closed, and deleting the window is what triggers the crash?

Also, please give us a stack trace whenever reporting crashes, there's not much we can guess without that!

Its crashing as it loses focus when we click some other application. The window is still visible on scree.

Here is the call stack

OpenGL Rendering (34)#0    0x00007fff94a2b286 in __pthread_kill ()
#1    0x00007fff8a9d842f in pthread_kill ()
#2    0x00007fff901b4b53 in abort ()
#3    0x000000011abea4bc in gpusKillClient ()
#4    0x0000123400002a8e in GhalInterface::getCommandBuffer(unsigned char**, unsigned char**, unsigned int*, unsigned int*) ()
#5    0x0000123400024658 in GHAL3D::CPrivateCommandTransport::FlushCommandBuffer(GHAL3D::FLUSH_TYPE, unsigned char) ()
#6    0x000012340002438d in g575SubmitPacketsToken ()
#7    0x00001234002e0761 in gldPresentFramebufferData ()
#8    0x000000011e7bb131 in glSwap_Exec ()
#9    0x00007fff9202bf9a in CGLFlushDrawable ()
#10    0x00007fff8d7b3544 in -[NSOpenGLContext flushBuffer] ()
#11    0x000000012898dd96 in juce::OpenGLContext::NativeContext::swapBuffers() at /Phototshop_plugin/Code/JUCE-3.1.1/modules/juce_opengl/native/juce_OpenGL_osx.h:141
#12    0x000000012898b5af in juce::OpenGLContext::swapBuffers() at /Phototshop_plugin/Code/JUCE-3.1.1/modules/juce_opengl/opengl/juce_OpenGLContext.cpp:745
#13    0x0000000128993944 in juce::OpenGLContext::CachedImage::renderFrame() at /Phototshop_plugin/Code/JUCE-3.1.1/modules/juce_opengl/opengl/juce_OpenGLContext.cpp:191
#14    0x00000001289964e1 in juce::OpenGLContext::CachedImage::run() at /Phototshop_plugin/Code/JUCE-3.1.1/modules/juce_opengl/opengl/juce_OpenGLContext.cpp:359
#15    0x00000001289965cc in non-virtual thunk to juce::OpenGLContext::CachedImage::run() at /Phototshop_plugin/Code/JUCE-3.1.1/modules/juce_opengl/opengl/juce_OpenGLContext.cpp:366
#16    0x0000000128c1833e in juce::Thread::threadEntryPoint() at /Phototshop_plugin/Code/JUCE-3.1.1/modules/juce_core/threads/juce_Thread.cpp:101
#17    0x0000000128c18595 in juce::juce_threadEntryPoint(void*) at /Phototshop_plugin/Code/JUCE-3.1.1/modules/juce_core/threads/juce_Thread.cpp:113
#18    0x0000000128c3649e in threadEntryProc at /Phototshop_plugin/Code/JUCE-3.1.1/modules/juce_core/native/juce_posix_SharedCode.h:861
#19    0x00007fff8a9d6268 in _pthread_body ()
#20    0x00007fff8a9d61e5 in _pthread_start ()
#21    0x00007fff8a9d441d in thread_start ()

There is a known issue on Mac when a window with an OpenGLContext closes. The crash happens just before the window is actually closed, but after the close call has already been issued. Can you check with other (working) photoshop plugins what happens when you click on a background window? Does the plug-in window close?

The window does not close in other plugins. It just loses the focus. Window will be still visible. 



And secondly, it's a very strange crash trace. The functions that's crashing is GhalInterface::getCommandBuffer, which seems to be an Intel driver class, and if you search online for this, you find lots of other people complaining about crashes in all sorts of apps.. I suspect it's a buggy driver, TBH.


Thanks for the link. I corrected it.
I tried in 3 MAC machines and all had same issue. I'll check with updated driver.