我注意到 UIWebView 中经常发生可重现的崩溃:这里是堆栈跟踪:
Incident Identifier: 4729DA31-A946-436D-97AC-EB3C8746E0FF
CrashReporter Key: 92eabebd7d2b07f27dde132a3c28d6bb7cf92df4
Hardware Model: iPad3,6
Process: ... [3120]
Path: /var/mobile/Applications/10173A06-48D0-48F7-A832-9AC6961B045D/...app/...
Identifier: ...
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2013-05-09 19:07:31.997 +0100
OS Version: iOS 6.1.3 (10B329)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000008
Crashed Thread: 2
...
Thread 2 name: WebThread
Thread 2 Crashed:
0 WebCore 0x3772a03a WebCore::ThreadTimers::sharedTimerFiredInternal() + 130
1 WebCore 0x37729f86 WebCore::timerFired(__CFRunLoopTimer*, void*) + 62
2 CoreFoundation 0x31741854 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 12
3 CoreFoundation 0x317414fe __CFRunLoopDoTimer + 270
4 CoreFoundation 0x31740172 __CFRunLoopRun + 1226
5 CoreFoundation 0x316b3238 CFRunLoopRunSpecific + 352
6 CoreFoundation 0x316b30c4 CFRunLoopRunInMode + 100
7 WebCore 0x37697390 RunWebThread(void*) + 440
8 libsystem_c.dylib 0x39a530de _pthread_start + 306
9 libsystem_c.dylib 0x39a52fa4 thread_start + 4
通过以下步骤发生:
- 让 UIWebView 加载请求(NSURLRequest)
- 在请求加载之前将应用程序发送到后台
- 等几分钟
- 从后台恢复应用程序会因示例堆栈跟踪信息而崩溃。
有谁知道为什么会这样?很感谢任何形式的帮助!
编辑: 用于执行请求的代码
- (void)viewDidLoad
{
[super viewDidLoad];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
[self.webView loadRequest:urlRequest];
}
我的 UIViewController 也是 UIWebView 的代表,我实现了以下方法:
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
-(void)webViewDidFinishLoad:(UIWebView *)webView
在调用任何这些方法之前,应用程序崩溃了。