1
我得到以下異常:在什麼行代碼發生這種例外?
-[NSView _registerWithBackdropView] should not be called off of the main thread. Invocation was here:
(
0 AppKit 0x00007fff7377c5ce -[NSView(NSInternal) _unregisterWithBackdropViewIfNeeded] + 404
1 AppKit 0x00007fff738b421d -[NSView(NSLayerKitGlue) _drawViewBackingLayer:inContext:drawingHandler:] + 789
2 AppKit 0x00007fff738b3f02 -[NSView(NSLayerKitGlue) drawLayer:inContext:] + 80
3 QuartzCore 0x00007fff7ba93e3d _ZN2CA5Layer8display_Ev + 1155
4 AppKit 0x00007fff738b2d9a _NSBackingLayerDisplay + 577
5 AppKit 0x00007fff738a6001 -[_NSViewBackingLayer display] + 885
6 QuartzCore 0x00007fff7ba87f6e _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 572
7 QuartzCore 0x00007fff7ba88099 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 35
8 QuartzCore 0x00007fff7ba7d878 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
9 QuartzCore 0x00007fff7b974631 _ZN2CA11Transaction6commitEv + 475
10 AppKit 0x00007fff73a201e6 -[NSUIHeartBeat _heartBeatThread:] + 2516
11 Foundation 0x00007fff77668c6d __NSThread__start__ + 1243
12 libsystem_pthread.dylib 0x00007fff8b439aab _pthread_body + 180
13 libsystem_pthread.dylib 0x00007fff8b4399f7 _pthread_body + 0
14 libsystem_pthread.dylib 0x00007fff8b4391fd thread_start + 13
)
我怎麼能知道在我的代碼行這種情況發生?
該應用程序不會崩潰,我只是看到Xcode的控制檯中的錯誤。
我知道問題是在主線程中執行的UI操作是而不是。但我甚至不知道我的代碼在哪裏發生。
似乎您使用的是嘗試進行某些UI調用的pthread。 –
@ Jean-BaptisteYunès是的,但我怎麼知道觸發它的代碼行? – jmoukel
檢測代碼和/或使用調試器。 –