iphone - 应用程序很少在辅助线程上更新 UI 时崩溃

标签 iphone ios ipad

这对我来说真的很奇怪,因为我的应用程序在 Debug模式下运行良好,当测试人员使用发布版本尝试时,它很少会崩溃。我从控制台日志和崩溃日志中了解到,某处 UI 正在尝试从辅助线程更新,但并非总是如此。

在崩溃点我的控制台日志说,

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

&设备崩溃日志崩溃线程描述&错误类型如下

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

我对这个修复不是很确定,因为我还没有在最后重现它。如果至少有人可以帮助我进行复制,那将是很大的帮助:)

最佳答案

您在后台线程中进行 GUI 更改,但根据苹果的说法,您不是在后台线程中更改 GUI...因此请使用 performSelectorOnMainThread 进行 GUI 更改

关于iphone - 应用程序很少在辅助线程上更新 UI 时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16714648/

相关文章:

c - xcode编译控制台应用程序-c编程

iOS:迁移coredata关系时的value expression函数是什么?

iphone - 在我的应用程序中显示页面的实际 URL 时出现问题

objective-c - 行背景被切断

iphone - 当 UIScrollview 停止滚动动画时获取标签的值

ios - IOS中的几个入口点

iphone - 如何在 iOS5 的分段控件中自定义突出显示的文本颜色?

ios - ios13 设备中的 Cordova 应用程序在单击或滑动操作时表现得很奇怪

ios - 使用 Objective-C 将 CoreData 添加到现有项目中

ios - ios 8.4模拟器在xcode 6.4中非常大吗?