Main Thread Checker: UI API called on a background thread: -[UIView init]
PID: 460, TID: 62011, Thread name: (none), Queue name: com.apple.root.background-qos, QoS: 9
Backtrace:
4 IQKeyboardManagerSwift 0x00000001025c8274 _T0So11UITextFieldCABycfcTO + 28
5 IQKeyboardManagerSwift 0x00000001025a8360 _T0So11UITextFieldCABycfC + 68
6 IQKeyboardManagerSwift 0x00000001025a7e90 _T022IQKeyboardManagerSwift0aB0CACycfc + 5196
7 IQKeyboardManagerSwift 0x00000001025a838c _T022IQKeyboardManagerSwift0aB0CACycfcTo + 28
8 IQKeyboardManagerSwift 0x00000001025a6a3c _T022IQKeyboardManagerSwift0aB0CACycfC + 32
9 IQKeyboardManagerSwift 0x00000001025c5920 globalinit_33_1804EA4A44CDC62F5B66EAD58B4692DC_func2 + 24
10 libdispatch.dylib 0x00000001043e545c _dispatch_client_callout + 16
11 libdispatch.dylib 0x00000001043e617c dispatch_once_f + 120
12 IQKeyboardManagerSwift 0x000000010259c4cc _T022IQKeyboardManagerSwift0aB0C06sharedB0ACyFZ6StaticL_V02kbB0ACfau + 56
13 IQKeyboardManagerSwift 0x000000010259c46c _T022IQKeyboardManagerSwift0aB0C06sharedB0ACyFZ + 24
14 eBeePartners 0x0000000100c9ef7c _T012eBeePartners11AppDelegateC11applicationSbSo13UIApplicationC_s10DictionaryVySC0F16LaunchOptionsKeyVypGSg022didFinishLaunchingWithI0tFyycfU_ + 52
15 eBeePartners 0x0000000100bd18c0 _T0Ix_IyB_TR + 48
16 libdispatch.dylib 0x00000001043e549c _dispatch_call_block_and_release + 24
17 libdispatch.dylib 0x00000001043e545c _dispatch_client_callout + 16
18 libdispatch.dylib 0x00000001043f6cd8 _dispatch_root_queue_drain + 1004
19 libdispatch.dylib 0x00000001043f6880 _dispatch_worker_thread3 + 136
20 libsystem_pthread.dylib 0x0000000181dab130 _pthread_wqthread + 1268
21 libsystem_pthread.dylib 0x0000000181daac30 start_wqthread + 4
2017-09-22 12:36:11.268059+0800 eBeePartners[460:62011] [reports] Main Thread Checker: UI API called on a background thread: -[UIView init]
PID: 460, TID: 62011, Thread name: (none), Queue name: com.apple.root.background-qos, QoS: 9
Backtrace:
4 IQKeyboardManagerSwift 0x00000001025c8274 _T0So11UITextFieldCABycfcTO + 28
5 IQKeyboardManagerSwift 0x00000001025a8360 _T0So11UITextFieldCABycfC + 68
6 IQKeyboardManagerSwift 0x00000001025a7e90 _T022IQKeyboardManagerSwift0aB0CACycfc + 5196
7 IQKeyboardManagerSwift 0x00000001025a838c _T022IQKeyboardManagerSwift0aB0CACycfcTo + 28
8 IQKeyboardManagerSwift 0x00000001025a6a3c _T022IQKeyboardManagerSwift0aB0CACycfC + 32
9 IQKeyboardManagerSwift 0x00000001025c5920 globalinit_33_1804EA4A44CDC62F5B66EAD58B4692DC_func2 + 24
10 libdispatch.dylib 0x00000001043e545c _dispatch_client_callout + 16
11 libdispatch.dylib 0x00000001043e617c dispatch_once_f + 120
12 IQKeyboardManagerSwift 0x000000010259c4cc _T022IQKeyboardManagerSwift0aB0C06sharedB0ACyFZ6StaticL_V02kbB0ACfau + 56
13 IQKeyboardManagerSwift 0x000000010259c46c _T022IQKeyboardManagerSwift0aB0C06sharedB0ACyFZ + 24
14 eBeePartners 0x0000000100c9ef7c _T012eBeePartners11AppDelegateC11applicationSbSo13UIApplicationC_s10DictionaryVySC0F16LaunchOptionsKeyVypGSg022didFinishLaunchingWithI0tFyycfU_ + 52
15 eBeePartners 0x0000000100bd18c0 _T0Ix_IyB_TR + 48
16 libdispatch.dylib 0x00000001043e549c _dispatch_call_block_and_release + 24
17 libdispatch.dylib 0x00000001043e545c _dispatch_client_callout + 16
18 libdispatch.dylib 0x00000001043f6cd8 _dispatch_root_queue_drain + 1004
19 libdispatch.dylib 0x00000001043f6880 _dispatch_worker_thread3 + 136
20 libsystem_pthread.dylib 0x0000000181dab130 _pthread_wqthread + 1268
21 libsystem_pthread.dylib 0x0000000181daac30 start_wqthread + 4
2017-09-22 12:36:22.758673+0800 eBeePartners[460:61967] [BoringSSL] Function nw_protocol_boringssl_input_finished: line 1389 Peer disconnected during the middle of a handshake. Sending errSSLFatalAlert(-9802) alert
2017-09-22 12:36:22.813732+0800 eBeePartners[460:61967] TIC TCP Conn Failed [2:0x1c0166900]: 3:-9802 Err(-9802)
2017-09-22 12:36:22.848609+0800 eBeePartners[460:61719] [MC] Lazy loading NSBundle MobileCoreServices.framework
2017-09-22 12:36:22.854700+0800 eBeePartners[460:61719] [MC] Loaded MobileCoreServices.framework
2017-09-22 12:36:22.864960+0800 eBeePartners[460:61719] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-09-22 12:36:22.898137+0800 eBeePartners[460:62011] *** Assertion failure in void _UIPerformResizeOfTextViewForTextContainer(NSLayoutManager *, UIView<NSTextContainerView> *, NSTextContainer *, NSUInteger)(), /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIFoundation/UIFoundation-543/UIFoundation/TextSystem/NSLayoutManager_Private.m:1619
2017-09-22 12:36:23.117424+0800 eBeePartners[460:62011] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only run on the main thread!'
*** First throw call stack:
(0x18217fd38 0x181694528 0x18217fc0c 0x182b0ec90 0x18c65a70c 0x18c65a194 0x18c689e4c 0x18c689b08 0x18c6b3f88 0x18b8ebf28 0x18b5b1218 0x18c1e697c 0x18b6613ec 0x1025c8274 0x1025a8360 0x1025a7e90 0x1025a838c 0x1025a6a3c 0x1025c5920 0x1043e545c 0x1043e617c 0x10259c4cc 0x10259c46c 0x100c9ef7c 0x100bd18c0 0x1043e549c 0x1043e545c 0x1043f6cd8 0x1043f6880 0x181dab130 0x181daac30)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
如何调试此代码?
答案 0 :(得分:0)
仅在升级到Xcode9 / Swift4后才出现此错误。正如评论中所提到的,原因是在后台线程中调用ui-operations。我不知道为什么它在升级之前一直在工作。
你在Xcode上看到这个错误被调试器冻结了,对吗?然后,左侧面板(称为&#34;调试导航器&#34;)显示调用堆栈并指示应用程序崩溃的行。您可以单击其中一个并获取代码。
在我的情况下,错误的原因是performSegue
试图在主线程上运行。
func downloadHandler() {
DispatchQueue.global(qos: .default).async(execute: {
DispatchQueue.main.async(execute: {
self.labelMessage.text = "Unzipping downloaded data..."
})
/* Unzipping something... */
// WRONG: This causes error
// self.performSegue(withIdentifier: "toViewController", sender: nil)
// FIXED: performSegue should be run on main thread.
DispatchQueue.main.async(execute: {
self.performSegue(withIdentifier: "toViewController", sender: nil)
})
})
}
仔细检查DispatchQueue
。最好从调试器停止的地方开始。