我们从客户那里看到的最常见的崩溃是来自 _WebTryThreadLock 的异常(0xbbadbeef 始终在 WebThread 中,线程 #2)。通常崩溃包含与我们的代码无关的其他线程(包括主线程)。我们无法在内部复制它。我们已经查看了代码中可能使用来自其他线程的 UIWebView 的情况,但我们一无所获。我们总是在 webview 的委托被释放之前取消设置它。
我们从各种设备以及我可以看到的任何 iOS 版本(在 5.x-current 范围内)都看到了这一点。根据日志,它似乎主要发生在应用程序从后台恢复时。
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0xbbadbeef
Crashed Thread: 2
Thread 0 name: Dispatch queue: com.apple.root.default-priority
Thread 0:
0 libsystem_kernel.dylib 0x328e31d4 madvise + 8
1 ImageIO 0x3306c550 CGImageRead_willNeed + 52
2 ImageIO 0x331bcd98 __copyImageBlockSetPNG_block_invoke_0 + 476
3 libdispatch.dylib 0x35d03a68 _dispatch_apply_serial + 16
4 libdispatch.dylib 0x35cf44b4 _dispatch_client_callout + 20
5 libdispatch.dylib 0x35d02886 _dispatch_sync_f_invoke + 22
6 ImageIO 0x331bb446 copyImageBlockSetPNG + 2102
7 ImageIO 0x3306b53e ImageProviderCopyImageBlockSetCallback + 510
8 CoreGraphics 0x33fc59d6 CGImageProviderCopyImageBlockSetWithOptions + 158
9 QuartzCore 0x3a4f474c CA::Render::create_image(CGImage*, CGColorSpace*, unsigned int) + 668
10 QuartzCore 0x3a4f433a CA::Render::copy_image(CGImage*, CGColorSpace*, unsigned int, double) + 254
11 QuartzCore 0x3a4f4226 CA::Render::prepare_image(CGImage*, CGColorSpace*, unsigned int, double) + 14
12 QuartzCore 0x3a4e2af0 CA::Layer::prepare_commit(CA::Transaction*) + 416
13 QuartzCore 0x3a4e221e CA::Context::commit_transaction(CA::Transaction*) + 242
14 QuartzCore 0x3a4e2024 CA::Transaction::commit() + 312
15 UIKit 0x3af260b6 -[UIApplication _reportAppLaunchFinished] + 38
[...]
Thread 2 name: WebThread
Thread 2 Crashed:
0 WebCore 0x379a99ca _WebTryThreadLock(bool) + 298
1 WebCore 0x379a988a WebRunLoopLock(__CFRunLoopObserver*, unsigned long, void*) + 42
2 CoreFoundation 0x336da6ca __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 18
3 CoreFoundation 0x336d89bc __CFRunLoopDoObservers + 272
4 CoreFoundation 0x336d8c8c __CFRunLoopRun + 604
5 CoreFoundation 0x3364beb8 CFRunLoopRunSpecific + 352
6 CoreFoundation 0x3364bd44 CFRunLoopRunInMode + 100
7 WebCore 0x379a7a40 RunWebThread(void*) + 440
8 libsystem_c.dylib 0x35d3e30e _pthread_start + 306
9 libsystem_c.dylib 0x35d3e1d4 thread_start + 4
[...]
Thread 5 name: JavaScriptCore::BlockFree
Thread 5:
0 libsystem_kernel.dylib 0x328f308c __psynch_cvwait + 24
1 libsystem_c.dylib 0x35d36d2a _pthread_cond_wait + 642
2 libsystem_c.dylib 0x35d36aa0 pthread_cond_timedwait + 40
3 JavaScriptCore 0x39b67c70 WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 104
4 JavaScriptCore 0x39c79552 JSC::BlockAllocator::blockFreeingThreadMain() + 78
5 JavaScriptCore 0x39c8bfa8 WTF::wtfThreadEntryPoint(void*) + 12
6 libsystem_c.dylib 0x35d3e30e _pthread_start + 306
7 libsystem_c.dylib 0x35d3e1d4 thread_start + 4
Thread 6 name: WebCore: CFNetwork Loader
Thread 6:
0 libsystem_kernel.dylib 0x328e2eb4 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x328e3048 mach_msg + 36
2 CoreFoundation 0x336da040 __CFRunLoopServiceMachPort + 124
3 CoreFoundation 0x336d8d9e __CFRunLoopRun + 878
4 CoreFoundation 0x3364beb8 CFRunLoopRunSpecific + 352
5 CoreFoundation 0x3364bd44 CFRunLoopRunInMode + 100
6 WebCore 0x37a42f6a WebCore::runLoaderThread(void*) + 138
7 JavaScriptCore 0x39c8bfa8 WTF::wtfThreadEntryPoint(void*) + 12
8 libsystem_c.dylib 0x35d3e30e _pthread_start + 306
9 libsystem_c.dylib 0x35d3e1d4 thread_start + 4