I'm working on a Cocoa application that leverages NSOpenGLView driven from a CVDisplayLink thread.
We've recently seen a number of crash reports (in the wild) with the following stack trace. 10.11 only.
#29. Crashed: com.apple.root.default-qos
0 libobjc.A.dylib 0x7fff933bb4dd objc_msgSend + 29
1 CoreGraphics 0x7fff9219f19e CGImageGetProperty + 52
2 QuartzCore 0x7fff93ae1312 CA::Render::create_image(CGImage*, CGColorSpace*, unsigned int) + 149
3 QuartzCore 0x7fff93ae0fe6 CA::Render::copy_image(CGImage*, CGColorSpace*, unsigned int, double) + 395
4 QuartzCore 0x7fff93aeeb6b CA::Render::copy_render_value(void const*, CGColorSpace* (*)()) + 278
5 AppKit 0x7fffa010fcec -[_NSCGLSurface _copyNonatomicRenderValue] + 296
6 QuartzCore 0x7fff93addc35 -[CALayer(CALayerPrivate) _copyRenderLayer:layerFlags:commitFlags:] + 557
7 QuartzCore 0x7fff93add59d CA::Context::commit_layer(CA::Layer*, unsigned int, unsigned int, void*) + 103
8 QuartzCore 0x7fff93add4ca CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 330
9 QuartzCore 0x7fff93adba72 CA::Context::commit_transaction(CA::Transaction*) + 1766
10 QuartzCore 0x7fff93adb0ec CA::Transaction::commit() + 508
11 AppKit 0x7fff9f9d95ae -[NSAnimation(NSInternal) _advanceTimeWithDisplayLink:] + 429
12 AppKit 0x7fff9f9d92ea -[NSScreenDisplayLink _fire] + 439
13 CoreFoundation 0x7fffa0b7bb94 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
14 CoreFoundation 0x7fffa0b7b823 __CFRunLoopDoTimer + 1075
15 CoreFoundation 0x7fffa0b7b37a __CFRunLoopDoTimers + 298
16 CoreFoundation 0x7fffa0b72871 __CFRunLoopRun + 1841
17 CoreFoundation 0x7fffa0b71ed8 CFRunLoopRunSpecific + 296
18 Foundation 0x7fff98c92ed9 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 270
19 AppKit 0x7fff9f93cd72 -[NSAnimation(NSInternal) _runBlocking] + 398
20 AppKit 0x7fff9f93cbcb -[NSAnimation(NSInternal) _animationThread] + 66
21 libdispatch.dylib 0x7fff8e85593d _dispatch_call_block_and_release + 12
22 libdispatch.dylib 0x7fff8e84a40b _dispatch_client_callout + 8
23 libdispatch.dylib 0x7fff8e84e29b _dispatch_root_queue_drain + 1890
24 libdispatch.dylib 0x7fff8e84db00 _dispatch_worker_thread3 + 91
25 libsystem_pthread.dylib 0x7fff90e4c4de _pthread_wqthread + 1129
26 libsystem_pthread.dylib 0x7fff90e4a341 start_wqthread + 13
We have a CVDisplayLink driven thread that is in the following state:
#35. CVDisplayLink
0 libsystem_platform.dylib 0x7fff9214ddbd _OSSpinLockLockSlow + 79
1 QuartzCore 0x7fff93ad88af -[CALayer setContents:] + 37
2 AppKit 0x7fff9fe302d7 flush_notify + 1169
3 GLEngine 0x7fff95e1ecda (Missing)
4 OpenGL 0x7fff9180effe CGLFlushDrawable + 66
When I set a symbolic breakpoint in CA::Render::create_image
, I cannot get it to hit in the com.apple.root.default-qos thread
. So I get first question - when does this stack happen in the QOS thread? (and not the main thread).
I should note that sometimes the crash happens a bit above (in CGImageGetProperty
). Any help would be appreciated.