OpenGL deadlocks (mac) :/


#1

Some context: back in April, due to OpenGL related crashes on Mac, calls to CGLLockContext an CGLUnlockContext were added. (relevant thread: http://rawmaterialsoftware.com/viewtopic.php?f=2&t=8909)

Now, those calls seemed to cause occasional deadlocks for our users using our plugins with Pro Tools.
Looking at the crash report, I see one thread is at:

...
CProcessType::SetViewPort(long, OpaqueGrafPtr*) + 85 (in AutoAlign) [0x36464265]
virtual thunk to JucePlugInProcess::SetViewPort(OpaqueGrafPtr*) + 29 (in AutoAlign) [0x364441d3]
JucePlugInProcess::SetViewPort(OpaqueGrafPtr*) + 57 (in AutoAlign) [0x36444211]
JucePlugInProcess::JuceCustomUIView::attachToWindow(OpaqueGrafPtr*) + 78 (in AutoAlign) [0x36444120]
juce::ScopedPointer<juce::Component>::operator=(juce::Component*) + 33 (in AutoAlign) [0x363d88d5]
JucePlugInProcess::JuceCustomUIView::EditorCompWrapper::~EditorCompWrapper() + 43 (in AutoAlign) [0x36443f05]
removeSubWindow(void*, juce::Component*) + 192 (in AutoAlign) [0x36442666]
juce::Component::removeFromDesktop() + 79 (in AutoAlign) [0x363a3aab]
juce::NSViewComponentPeer::~NSViewComponentPeer() + 107 (in AutoAlign) [0x363f354b]
-[NSView removeFromSuperview] + 367 (in AppKit) [0x92a24911]
-[NSView _setWindow:] + 1934 (in AppKit) [0x929d6da1]
CFArrayApplyFunction + 224 (in CoreFoundation) [0x903fa220]
__NSViewRecursionHelper + 40 (in AppKit) [0x92a262dd]
-[NSView _setWindow:] + 1696 (in AppKit) [0x929d6cb3]
-[NSSurface setWindow:] + 51 (in AppKit) [0x92aeedc1]
-[NSSurface _disposeSurface] + 145 (in AppKit) [0x92aef398]
-[NSNotificationCenter postNotificationName:object:] + 56 (in Foundation) [0x9aa4105d]
-[NSNotificationCenter postNotificationName:object:userInfo:] + 128 (in Foundation) [0x9aa33c50]
_CFXNotificationPostNotification + 186 (in CoreFoundation) [0x9042016a]
__CFXNotificationPost + 947 (in CoreFoundation) [0x90420763]
_nsnote_callback + 176 (in Foundation) [0x9aa3edb3]
CGLClearDrawable + 58 (in OpenGL) [0x94452a48]
semaphore_wait_signal_trap + 10 (in libSystem.B.dylib) [0x9615eb42]

and another thread is at:

...
non-virtual thunk to juce::OpenGLContext::CachedImage::run() + 20 (in AutoAlign) [0x3642fbb3]
juce::OpenGLContext::CachedImage::run() + 116 (in AutoAlign) [0x3642fb32]
juce::OpenGLContext::CachedImage::renderFrame() + 156 (in AutoAlign) [0x3643050a]
juce::OpenGLContext::CachedImage::paintComponent() + 43 (in AutoAlign) [0x36430249]
juce::MessageManagerLock::MessageManagerLock(juce::Thread*) + 40 (in AutoAlign) [0x362f8f8c]
juce::MessageManagerLock::attemptLock(juce::Thread*, juce::ThreadPoolJob*) + 256 (in AutoAlign) [0x362f8e96]
juce::WaitableEvent::wait(int) const + 26 (in AutoAlign) [0x362bafa4]
juce::WaitableEventImpl::wait(int) + 168 (in AutoAlign) [0x362e3fe8]
pthread_cond_timedwait$UNIX2003 + 72 (in libSystem.B.dylib) [0x9618c2b1]
__semwait_signal + 10 (in libSystem.B.dylib) [0x9618caa2]

Seems like:

  • the OpenGL drawing thread is trying to obtain the “MessageManagerLock” while the OpenGL context is being locked by juce::OpenGLContext::CachedImage::renderFrame()
  • the main thread has the MessageManagerLock locked (juce::Component::removeFromDesktop() has CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN line probably meaning that it’s locked?) but then calls CGLClearDrawable which apparently tries to take the lock.

Which explains the deadlock.

We’re currently testing a fix which just splits the OpenGL locking scopes at the rendering thread to several ones, where the one that locks the MessageManager, locks the MessageManager first and then the OpenGL lock, so that the locking order is consistent (see https://github.com/yairchu/JUCE/commit/2ebe1f279b918ff06bb91300169361a97a63a8ee). Btw i’m somewhat ignorant of the juce internals, what does the MessageManager do? :slight_smile:

It’s kinda difficult to tell if the problem was solved or not as the deadlocks have been somewhat difficult to reproduce…

cheers, Yair


#2

I did fix a GL threading problem last week… Not 100% sure if it’s the same thing, but it looks similar.


#3

It seems like a different GL threading issue, because we did reproduce the problem with a build which had jules updated from thursday - 7a1c8f61a5bb0f590b4d65d324cc740462755443, and the “OpenGL threading fix” commit (e04fba6f4241f542453dbe54500bdab3b474fb0e) is from tuesday.

To reproduce it we had to open pro tools, open auto-align plugin window, close it and open another one, and if that didn’t crash, close PT and retry and retry and retry until it crashes (or with the fix, it doesn’t seem to crash no matter how many times you retry)…

But other than it having been reproduced, the code also does seem to have the problem (inconsistent locking order) too…


#4

Hmm, ok. Well, the OpenGLContext won’t be able to cope very well when its window gets deleted without first allowing it to detach itself… Perhaps a fix would be as simple as adding this:

~EditorCompWrapper() { removeChildComponent (editorComp);

…?


#5

I’ve also got the deadlock problem when using OpenGL in a VST, OSX 10.6.

I’ve basically just taken the OpenGL demo code from the Juce Demo app and added it to the naked VST skeleton plugin created by Introjucer 3.0.0.
Using Juce modules version 2.0.24.

Deadlock happens whenever I close the VST window. Same thing happens with all VST hosts I’ve tried (Juce Plugin Host, Max/MSP, Ableton…).

I don’t know enough about the internals of JUCE to fix this on my own. Please help :wink:


#6

Well what are the two deadlocking stack traces?


#7

Stack trace shows MessageManagerLock, etc… in one thread, and juce::Component::removeFromDesktop(), etc… in another thread.

The DemoOpenGLCanvas destructor calls the detach() method of OpenGLContext. Shouldn’t that prevent this problem?

[code]Date/Time: 2012-09-13 11:44:11 -0700
OS Version: 10.6.8 (Build 10K549)
Architecture: x86_64
Report Version: 7

Command: Plugin Host
Path: /Users/scottawardle/Library/Developer/Xcode/DerivedData/Plugin_Host-ejxmhciwyhrzridkvciuthmpzvci/Build/Products/Release/PluginHost.app/Contents/MacOS/Plugin Host
Version: 1.0.0 (1.0.0)
Parent: launchd [202]

PID: 5902
Event: hang
Duration: 5.48s (sampling started after 2 seconds)
Steps: 14 (100ms sampling interval)

Pageins: 0
Pageouts: 0

Process: Plugin Host [5902]
Path: /Users/scottawardle/Library/Developer/Xcode/DerivedData/Plugin_Host-ejxmhciwyhrzridkvciuthmpzvci/Build/Products/Release/PluginHost.app/Contents/MacOS/Plugin Host
UID: 501

Thread 35ed1 DispatchQueue 100
User stack:
14 ??? (in Plugin Host + 5589) [0x25d5]
14 ??? (in Plugin Host + 1510560) [0x171ca0]
14 ??? (in Plugin Host + 1510245) [0x171b65]
14 ??? (in Plugin Host + 623870) [0x994fe]
14 -[NSApplication run] + 821 (in AppKit) [0x9a2421f3]
14 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 156 (in AppKit) [0x9a27fdd6]
14 _DPSNextEvent + 847 (in AppKit) [0x9a280595]
14 BlockUntilNextEventMatchingListInMode + 81 (in HIToolbox) [0x9599fa3e]
14 ReceiveNextEventCommon + 158 (in HIToolbox) [0x9599faf5]
14 RunCurrentEventLoopInMode + 392 (in HIToolbox) [0x9599fe04]
14 CFRunLoopRunInMode + 97 (in CoreFoundation) [0x92d3d1f1]
14 CFRunLoopRunSpecific + 452 (in CoreFoundation) [0x92d3d3c4]
14 __CFRunLoopRun + 1071 (in CoreFoundation) [0x92d3deef]
14 __CFRunLoopDoSources0 + 1201 (in CoreFoundation) [0x92d402c1]
14 __NSThreadPerformPerform + 506 (in Foundation) [0x90740671]
14 ??? (in Plugin Host + 1516203) [0x1732ab]
14 ??? (in Plugin Host + 1527971) [0x1760a3]
14 ??? (in Plugin Host + 1527790) [0x175fee]
14 ??? (in Plugin Host + 1485073) [0x16b911]
14 ??? (in Plugin Host + 1119726) [0x1125ee]
14 ??? (in Plugin Host + 1548101) [0x17af45]
14 ??? (in Plugin Host + 1693216) [0x19e620]
14 ??? (in Plugin Host + 1693637) [0x19e7c5]
14 ??? (in Plugin Host + 1104474) [0x10ea5a]
14 ??? (in Plugin Host + 1130732) [0x1150ec]
14 ??? (in Plugin Host + 1128053) [0x114675]
14 ??? (in Plugin Host + 1548566) [0x17b116]
14 ??? (in Plugin Host + 1609386) [0x189eaa]
14 ??? (in Plugin Host + 14671) [0x494f]
14 ??? (in Plugin Host + 14740) [0x4994]
14 ??? (in Plugin Host + 1264181) [0x135a35]
14 ??? (in Plugin Host + 1545954) [0x17a6e2]
14 ??? (in Plugin Host + 259697) [0x40671]
14 ??? (in Plugin Host + 260202) [0x4086a]
14 ??? (in Plugin Host + 260599) [0x409f7]
14 ??? (in Plugin Host + 261419) [0x40d2b]
14 ??? (in Plugin Host + 253897) [0x3efc9]
14 ??? (in Plugin Host + 260738) [0x40a82]
14 ??? (in Plugin Host + 205666) [0x33362]
14 AudioEffect::dispatchEffectClass(AEffect*, int, int, int, void*, float) + 61 (in VST_VBAP) [0x1458ef9d]
14 JuceVSTWrapper::dispatcher(int, int, int, void*, float) + 310 (in VST_VBAP) [0x14590606]
14 JuceVSTWrapper::deleteEditor(bool) + 154 (in VST_VBAP) [0x1459251a]
14 juce::detachComponentFromWindowRef(juce::Component*, void*) + 392 (in VST_VBAP) [0x14593708]
14 juce::Component::removeFromDesktop() + 79 (in VST_VBAP) [0x14496d6f]
14 juce::NSViewComponentPeer::~NSViewComponentPeer() + 17 (in VST_VBAP) [0x1453c931]
14 juce::NSViewComponentPeer::~NSViewComponentPeer() + 104 (in VST_VBAP) [0x1453dbf8]
14 -[NSView removeFromSuperview] + 367 (in AppKit) [0x9a2a1911]
14 -[NSView _setWindow:] + 1934 (in AppKit) [0x9a253da1]
14 CFArrayApplyFunction + 224 (in CoreFoundation) [0x92d36220]
14 __NSViewRecursionHelper + 40 (in AppKit) [0x9a2a32dd]
14 -[NSView _setWindow:] + 1696 (in AppKit) [0x9a253cb3]
14 -[NSSurface setWindow:] + 51 (in AppKit) [0x9a36bdc1]
14 -[NSSurface _disposeSurface] + 145 (in AppKit) [0x9a36c398]
14 -[NSNotificationCenter postNotificationName:object:] + 56 (in Foundation) [0x9072c05d]
14 -[NSNotificationCenter postNotificationName:object:userInfo:] + 128 (in Foundation) [0x9071ec50]
14 _CFXNotificationPostNotification + 186 (in CoreFoundation) [0x92d5c16a]
14 __CFXNotificationPost + 947 (in CoreFoundation) [0x92d5c763]
14 _nsnote_callback + 176 (in Foundation) [0x90729db3]
14 CGLClearDrawable + 58 (in OpenGL) [0x998aba48]
14 semaphore_wait_signal_trap + 10 (in libSystem.B.dylib) [0x91c8fb42]
Kernel stack:
14 semaphore_wait_continue + 0 [0x22a88f]

Thread 35eda DispatchQueue 1634545000
User stack:
14 start_wqthread + 30 (in libSystem.B.dylib) [0x91cb55c6]
14 _pthread_wqthread + 390 (in libSystem.B.dylib) [0x91cb5781]
14 _dispatch_worker_thread2 + 240 (in libSystem.B.dylib) [0x91cb5cfe]
14 _dispatch_queue_invoke + 163 (in libSystem.B.dylib) [0x91cb5f59]
14 kevent + 10 (in libSystem.B.dylib) [0x91cb6382]
Kernel stack:
14 kevent + 97 [0x47a699]

Thread 35ee9
User stack:
14 thread_start + 34 (in libSystem.B.dylib) [0x91cbd0de]
14 _pthread_start + 345 (in libSystem.B.dylib) [0x91cbd259]
14 CAPThread::Entry(CAPThread*) + 140 (in CoreAudio) [0x98070488]
14 HP_IOThread::ThreadEntry(HP_IOThread*) + 17 (in CoreAudio) [0x98070571]
14 HP_IOThread::WorkLoop() + 1892 (in CoreAudio) [0x98070cda]
14 CAGuard::WaitUntil(unsigned long long) + 289 (in CoreAudio) [0x980733dd]
14 CAGuard::WaitFor(unsigned long long) + 219 (in CoreAudio) [0x980703ab]
14 pthread_cond_timedwait_relative_np + 47 (in libSystem.B.dylib) [0x91cec5a8]
14 semaphore_timedwait_signal_trap + 10 (in libSystem.B.dylib) [0x91c8fb5a]
Kernel stack:
14 semaphore_wait_continue + 0 [0x22a88f]

Thread 35eeb
User stack:
14 thread_start + 34 (in libSystem.B.dylib) [0x91cbd0de]
14 _pthread_start + 345 (in libSystem.B.dylib) [0x91cbd259]
14 CAPThread::Entry(CAPThread*) + 140 (in CoreAudio) [0x98070488]
14 HP_IOThread::ThreadEntry(HP_IOThread*) + 17 (in CoreAudio) [0x98070571]
14 HP_IOThread::WorkLoop() + 1892 (in CoreAudio) [0x98070cda]
14 CAGuard::WaitUntil(unsigned long long) + 289 (in CoreAudio) [0x980733dd]
14 CAGuard::WaitFor(unsigned long long) + 219 (in CoreAudio) [0x980703ab]
14 pthread_cond_timedwait_relative_np + 47 (in libSystem.B.dylib) [0x91cec5a8]
14 semaphore_timedwait_signal_trap + 10 (in libSystem.B.dylib) [0x91c8fb5a]
Kernel stack:
14 semaphore_wait_continue + 0 [0x22a88f]

Thread 35eec
User stack:
14 thread_start + 34 (in libSystem.B.dylib) [0x91cbd0de]
14 _pthread_start + 345 (in libSystem.B.dylib) [0x91cbd259]
14 CAPThread::Entry(CAPThread*) + 96 (in CoreMIDI) [0x2a5ca6]
14 XThread::RunHelper(void*) + 17 (in CoreMIDI) [0x2a62d9]
14 MIDIProcess::RunMIDIInThread() + 150 (in CoreMIDI) [0x2c397a]
14 XServerMachPort::ReceiveMessage(int&, void*, int&) + 155 (in CoreMIDI) [0x2a50c1]
14 mach_msg_trap + 10 (in libSystem.B.dylib) [0x91c8fafa]
Kernel stack:
14 ipc_mqueue_receive_continue + 0 [0x210d84]

Thread 35f2c
User stack:
14 thread_start + 34 (in libSystem.B.dylib) [0x91cbd0de]
14 _pthread_start + 345 (in libSystem.B.dylib) [0x91cbd259]
14 ??? (in Plugin Host + 496271) [0x7a28f]
14 ??? (in Plugin Host + 429578) [0x69e0a]
14 ??? (in Plugin Host + 631020) [0x9b0ec]
14 ??? (in Plugin Host + 431087) [0x6a3ef]
14 ??? (in Plugin Host + 529491) [0x82453]
14 pthread_cond_timedwait$UNIX2003 + 72 (in libSystem.B.dylib) [0x91cbd2b1]
14 __semwait_signal + 10 (in libSystem.B.dylib) [0x91cbdaa2]
Kernel stack:
14 semaphore_wait_continue + 0 [0x22a88f]

Thread 35f42
User stack:
14 thread_start + 34 (in libSystem.B.dylib) [0x91cbd0de]
14 _pthread_start + 345 (in libSystem.B.dylib) [0x91cbd259]
14 threadEntryProc + 70 (in VST_VBAP) [0x143de6a6]
14 juce::Thread::threadEntryPoint() + 103 (in VST_VBAP) [0x143c4fb7]
14 non-virtual thunk to juce::OpenGLContext::CachedImage::run() + 20 (in VST_VBAP) [0x14582774]
14 juce::OpenGLContext::CachedImage::run() + 271 (in VST_VBAP) [0x1458268f]
14 juce::OpenGLContext::CachedImage::renderFrame() + 189 (in VST_VBAP) [0x1458283d]
14 non-virtual thunk to DemoOpenGLCanvas::renderOpenGL() + 20 (in VST_VBAP) [0x14301da4]
14 DemoOpenGLCanvas::renderOpenGL() + 83 (in VST_VBAP) [0x143018c3]
14 juce::MessageManagerLock::MessageManagerLock(juce::Thread*) + 40 (in VST_VBAP) [0x14406858]
14 juce::MessageManagerLock::attemptLock(juce::Thread*, juce::ThreadPoolJob*) + 584 (in VST_VBAP) [0x14406b58]
14 juce::WaitableEvent::wait(int) const + 26 (in VST_VBAP) [0x143c476a]
14 juce::WaitableEventImpl::wait(int) + 192 (in VST_VBAP) [0x143e9480]
14 pthread_cond_timedwait$UNIX2003 + 72 (in libSystem.B.dylib) [0x91cbd2b1]
14 __semwait_signal + 10 (in libSystem.B.dylib) [0x91cbdaa2]
Kernel stack:
14 semaphore_wait_continue + 0 [0x22a88f]

Thread 35f44
User stack:
14 thread_start + 34 (in libSystem.B.dylib) [0x91cbd0de]
14 _pthread_start + 345 (in libSystem.B.dylib) [0x91cbd259]
14 threadEntryProc + 70 (in VST_VBAP) [0x143de6a6]
14 juce::Thread::threadEntryPoint() + 103 (in VST_VBAP) [0x143c4fb7]
14 juce::timer::TimerThread::run() + 170 (in VST_VBAP) [0x1440b54a]
14 juce::Thread::wait(int) const + 27 (in VST_VBAP) [0x143c589b]
14 juce::WaitableEventImpl::wait(int) + 192 (in VST_VBAP) [0x143e9480]
14 pthread_cond_timedwait$UNIX2003 + 72 (in libSystem.B.dylib) [0x91cbd2b1]
13 __semwait_signal + 10 (in libSystem.B.dylib) [0x91cbdaa2]
1 _pthread_cond_wait + 1552 (in libSystem.B.dylib) [0x91cbd8c7]
1 pthread_mutex_lock + 627 (in libSystem.B.dylib) [0x91c956cf]
1 __spin_lock + 13 (in commpage [libSystem.B.dylib]) [0xffff026d]
Kernel stack:
12 semaphore_wait_continue + 0 [0x22a88f]
1 lo_unix_scall + 280 [0x2a1fd8]
1 unix_syscall + 579 [0x4f7f90]
1 __semwait_signal_nocancel + 273 [0x48e04f]
1 semaphore_timedwait_signal_trap_internal + 226 [0x22ad74]
1 semaphore_destroy + 825 [0x22ac50]
1 thread_block + 33 [0x227654]
1 thread_block_reason + 309 [0x2275b0]
1 thread_go + 1961 [0x22698c]
1 thread_setrun + 1360 [0x225bba]
1 machine_idle + 239 [0x2ad11b]
1 lo_allintrs + 302 [0x2a1c2e]
1 interrupt + 192 [0x2ab423]
1 lapic_interrupt + 108 [0x2b32f2]
1 mp_kdp_exit + 868 [0x2b4560]
1 sync_iss_to_iks + 124 [0x2aabf6]

Binary Images:
0x1000 - 0x23aff3 com.rawmaterialsoftware.pluginhost 1.0.0 (1.0.0) /Users/scottawardle/Library/Developer/Xcode/DerivedData/Plugin_Host-ejxmhciwyhrzridkvciuthmpzvci/Build/Products/Release/PluginHost.app/Contents/MacOS/Plugin Host
0x295000 - 0x2e1ffb com.apple.audio.midi.CoreMIDI 1.7.1 (42) /System/Library/Frameworks/CoreMIDI.framework/Versions/A/CoreMIDI
0x142ff000 - 0x147b8ff7 com.scea.VST_VBAP 1.0.0 (1.0.0) <0E55E5AE-1DC8-3B6F-B68A-57F7494C3696> /Users/scottawardle/Library/Audio/Plug-Ins/VST/VST_VBAP.vst/Contents/MacOS/VST_VBAP
0x90714000 - 0x90985fef com.apple.Foundation 6.6.8 (751.63) <69B3441C-B196-F2AD-07F8-D8DD24E4CD8C> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
0x91c8f000 - 0x91e36ff7 libSystem.B.dylib ??? (???) <2DCD13E3-1BD1-6F25-119A-3863A3848B90> /usr/lib/libSystem.B.dylib
0x92d01000 - 0x92e7cfe7 com.apple.CoreFoundation 6.6.6 (550.44) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x9596b000 - 0x95c8ffef com.apple.HIToolbox 1.6.5 (???) <21164164-41CE-61DE-C567-32E89755CB34> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
0x98050000 - 0x980cafff com.apple.audio.CoreAudio 3.2.6 (3.2.6) <156A532C-0B60-55B0-EE27-D02B82AA6217> /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
0x998a9000 - 0x998b7ff7 com.apple.opengl 1.6.14 (1.6.14) <82622F67-E032-0BF6-A78D-50B346E8D0FD> /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
0x9a238000 - 0x9ab1bff7 com.apple.AppKit 6.6.8 (1038.36) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
0xffff0000 - 0xffff1fff commpage [libSystem.B.dylib] ??? (???) <2DCD13E3-1BD1-6F25-119A-3863A3848B90> /usr/lib/libSystem.B.dylib
[/code]


#8

Have you made sure that detach() gets called before the component is removed from its parent? Maybe try stepping through detach() and see what happens in there - might find some clues…


#9

I’m new to XCode 4.xxx and can’t find how to actually run the debugger with the VST project created by Introjucer 3.0.0. Doh!!
What’s the best way to setup for debugging this VST with Xcode 4.xxx?
I used to have it all setup fine with XCode 3.whatever and used the debug build of the Juce Plugin Host.

Another big problem I’m having is that with the new juce modules (2.0.27) the “Plugin Host” no longer builds! Xcode throws up a ton
of errors that all stem from function calling syntax having changed for a wide range of classes. Is the code for the Plugin Host really so out-of-sync with the current juce modules? Is there an updated project file and code for the Plugin Host that will compile properly against modules 2.0.27?

Argh! :wink:


#10

Got debugging running on the VST now. Hopefully I can figure out why the detach() method isn’t having the effect that it should.

Still got the problem with being unable to build Plugin Host.


#11

~DemoOpenGLCanvas(), which calls detach(), never gets called when the Editor Window is closed! Doh!

Execution hangs in ~NSViewComponentPeer(), and the stack trace I previously posted gives more detailed information…

I don’t know enough about the inner workings of Juce to understand why the destructor for the editor window I derive
never gets called when the user clicks on the close button ;-(


#12

Hang on… Looking again, this has nothing to do with the detach() call.

What you’ve got is a deadlock between some kind of internal system GL mutex, and the event queue. Because the demo code is trying to get a MessageManagerLock inside the GL callback, when it already has an active GL context, then the OS has presumably also locked this mysterious GL lock. So that thread’s waiting for the event queue, but the event queue is - deep inside OSX’s own windowing code - waiting for that GL lock because the window is being closed. Nasty!

Easy fix: Don’t use a MessageManagerLock in your GL code!

Harder fix: Changing the VST code to make sure the editor comp is deleted before closing the window would probably fix it, but is a bit messy to do… I’ll have a look at that, but may decide to leave it up to you to just keep your GL thread lock-free.


#13

Looking at the latest changes to the OpenGL context code,


(due to needing to merge with my own modifications for this deadlocks issue)

I see that now the MessageManagerLock is always acquired before the context lock.
Awesome! I believe this problem is solved now. cheers