辅助线程上的UI更新很少导致应用程序崩溃 [英] Application crashes very rarely with UI update on secondary thread
问题描述
对于我来说,这真的很奇怪,因为我的应用在调试模式下可以正常运行&当测试人员尝试将发布版本为 RARELY 进行发行时,它会崩溃.我从控制台日志中了解到的内容崩溃日志是某处UI试图从辅助线程进行更新,但并非总是如此.
It is really very strange for me as my app is working fine at debug mode & when tried by tester with release build RARELY it gives crash. What I have understood from console log & crash log is that somewhere UI is trying to update from secondary thread but NOT always.
在崩溃点,我的控制台日志显示,
At crash point my console log says,
MyApp[715] <Warning>: CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces.May 21 10:51:25
MyApp[715] <Warning>: bool _WebTryThreadLock(bool), 0x1e1dd280: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...May 21 10:51:25
MyApp[715] <Notice>: 1 0x38b048f7 WebThreadLock
&设备崩溃日志崩溃线程描述&错误类型如下
& device crash logs crash thread description & error type are as below
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0xbbadbeef
Crashed Thread: 15
.
.
.
Thread 15 Crashed: 0
WebCore 0x38b03944_WebTryThreadLock(bool) + 164 1
WebCore 0x38b048f2 WebThreadLock + 62 2
UIKit 0x374424f6 -[UIWebTiledView layoutSubviews] + 38 3
UIKit 0x374424c6 -[UIWebDocumentView layoutSubviews] + 106 4
UIKit 0x373bb7fe -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 254 5
QuartzCore 0x30e92d5e -[CALayer layoutSublayers] + 210 6
QuartzCore 0x30e928fc CA::Layer::layout_if_needed(CA::Transaction*) + 456 7
QuartzCore 0x30e93830 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 12 8
QuartzCore 0x30e93216 CA::Context::commit_transaction(CA::Transaction*) + 234 9
QuartzCore 0x30e93024 CA::Transaction::commit() + 312 10
QuartzCore 0x30ed9df6 CA::Transaction::release_thread(void*) + 166 11 libsystem_c.dylib 0x31150128 _pthread_tsd_cleanup + 172 12
libsystem_c.dylib 0x3114fdfe _pthread_exit + 114 13
libsystem_c.dylib 0x31169160 pthread_exit + 24 14
Foundation 0x358bf226 +[NSThread exit] + 6 15
Foundation 0x35936696 __NSThread__main__ + 998 16
libsystem_c.dylib 0x3115d30e _pthread_start + 306 17
libsystem_c.dylib 0x3115d1d4 thread_start + 4
Thread 15 crashed with ARM Thread State (32-bit): r0: 0xbbadbeef r1: 0x00000000 r2: 0x030ba404 r3: 0x00000001 r4: 0x1e1dd280 r5: 0x3b4cacc0 r6: 0x00000000 r7: 0x030baa74 r8: 0x00000028 r9: 0x00006200 r10: 0x00000000 r11: 0x030bbc70 ip: 0x3b4061e0 sp: 0x030baa6c lr: 0x38b0393b pc: 0x38b03944 cpsr: 0x60000030
我不太确定此修复程序,因为我还没有在最后复制它.如果至少有人可以帮助我进行复制,那将是很大的帮助:)
I am not very sure about this fix as i have not yet reproduced it at my end. If anyone at-least could help me out for reproducing then it would be great help :)
推荐答案
This may be a result of calling to UIKit from a secondary thread.
更新主线程上的用户界面.在任何情况下,如果在单独的 thread
中执行 UI
更新,则原因将无效.一种选择是大型中央调度因为它在后台线程中执行操作,并且完全不会崩溃.
Update the user interface on the main thread.In any of the case for doing UI
updates in Separate thread
reason will be invalid. One Option is Grand Central Dispatch as it do things in background threads and no crash at all.
这篇关于辅助线程上的UI更新很少导致应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!