WebCore 的崩溃是不是意味着它必然与 UIWebView 相关?

Posted

技术标签:

【中文标题】WebCore 的崩溃是不是意味着它必然与 UIWebView 相关?【英文标题】:Does a crash of WebCore mean it is necessarily related to a UIWebView?WebCore 的崩溃是否意味着它必然与 UIWebView 相关? 【发布时间】:2012-08-12 13:04:03 【问题描述】:

我的应用广泛使用 UIWebView,因为它本质上是一个基于 WebView 的应用。

在应用程序的左侧,我有一个滑出菜单,类似于 Facebook 和 Path 应用程序。选择其中一个表格行会将主 web 视图滑回并加载 URL。

我已经从 Web 线程中看到了 WebCore 的随机崩溃,但我根本无法理解如何解决它。我测试了僵尸和内存分配,但应用程序始终保持在 3-4MB 的活动字节内。

我不知道它是否相关,但是当 webview 加载它的页面时有很大的“钩子”。例如,在 shouldStartLoad 中,我检查某些 URL,然后在页面上调用 JS 函数。我不知道这是否会导致崩溃。

崩溃日志显示 webcore 崩溃的不同区域。我在下面添加了一些最新的变体,但我不确定这些是所有可能的变体。

简而言之,什么是 WebCore 崩溃?它是 UIWebView 中的一个我无能为力的错误吗?谢谢!

Thread 2 name:  WebThread
Thread 2 Crashed:
0   WebCore                         0x32c540c0 WebCore::Document::body() const + 4
1   WebCore                         0x32d04052 WebCore::CachedResourceLoader::preload(WebCore::CachedResource::Type, WTF::String const&, WTF::String const&, bool) + 18
2   WebCore                         0x32d03ebe WebCore::htmlPreloadScanner::processToken() + 1510
3   WebCore                         0x32d03872 WebCore::HTMLPreloadScanner::scan() + 42
4   WebCore                         0x32cebc24 WebCore::HTMLDocumentParser::append(WebCore::SegmentedString const&) + 92
5   WebCore                         0x32cbce20 WebCore::DecodedDataDocumentParser::appendBytes(WebCore::DocumentWriter*, char const*, int, bool) + 200
6   WebCore                         0x32ceb8d0 WebCore::DocumentWriter::addData(char const*, int, bool) + 48
7   WebCore                         0x32ce5c3e WebCore::DocumentLoader::commitData(char const*, int) + 122
8   WebKit                          0x358cbc9a -[WebHTMLRepresentation receivedData:withDataSource:] + 158
9   WebKit                          0x358cbb10 -[WebDataSource(WebInternal) _receivedData:] + 164
10  WebKit                          0x358cba48 WebFrameLoaderClient::committedLoad(WebCore::DocumentLoader*, char const*, int) + 100
11  WebCore                         0x32ce2a48 WebCore::DocumentLoader::commitLoad(char const*, int) + 120
12  WebCore                         0x32ce29b4 WebCore::DocumentLoader::receivedData(char const*, int) + 72
13  WebCore                         0x32ce25da WebCore::ResourceLoader::didReceiveData(char const*, int, long long, bool) + 34
14  WebCore                         0x32ce2566 WebCore::MainResourceLoader::didReceiveData(char const*, int, long long, bool) + 474
15  WebCore                         0x32ce22b2 WebCore::ResourceLoader::didReceiveData(WebCore::ResourceHandle*, char const*, int, int) + 42
16  WebCore                         0x32ce2234 WebCore::ResourceHandle::handleDataArray(__CFArray const*) + 212
17  WebCore                         0x32ce2156 WebCore::didReceiveDataArray(_CFURLConnection*, __CFArray const*, void const*) + 34
18  CFNetwork                       0x370dd058 URLConnectionClient::_clientDidReceiveData(__CFArray const*, URLConnectionClient::ClientConnectionEventQueue*) + 220
19  CFNetwork                       0x370434b0 URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) + 436
20  CFNetwork                       0x3704319c URLConnectionClient::processEvents() + 100
21  CFNetwork                       0x370430d2 MultiplexerSource::perform() + 150
22  CoreFoundation                  0x3738aacc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 8
23  CoreFoundation                  0x3738a32e __CFRunLoopDoSources0 + 358
24  CoreFoundation                  0x3738903e __CFRunLoopRun + 646
25  CoreFoundation                  0x3730c49e CFRunLoopRunSpecific + 294
26  CoreFoundation                  0x3730c366 CFRunLoopRunInMode + 98
27  WebCore                         0x32cb5c9c RunWebThread(void*) + 396
28  libsystem_c.dylib               0x33c2b72e _pthread_start + 314
29  libsystem_c.dylib               0x33c2b5e8 thread_start + 0

Thread 2 name:  WebThread
Thread 2 Crashed:
0   WebCore                         0x32cbe120 WebCore::HTMLDocumentParser::pumpTokenizer(WebCore::HTMLDocumentParser::SynchronousMode) + 312
1   WebCore                         0x32cebc66 WebCore::HTMLDocumentParser::append(WebCore::SegmentedString const&) + 158
2   WebCore                         0x32cbce20 WebCore::DecodedDataDocumentParser::appendBytes(WebCore::DocumentWriter*, char const*, int, bool) + 200
3   WebCore                         0x32ceb8d0 WebCore::DocumentWriter::addData(char const*, int, bool) + 48
4   WebCore                         0x32ce5c3e WebCore::DocumentLoader::commitData(char const*, int) + 122
5   WebKit                          0x358cbc9a -[WebHTMLRepresentation receivedData:withDataSource:] + 158
6   WebKit                          0x358cbb10 -[WebDataSource(WebInternal) _receivedData:] + 164
7   WebKit                          0x358cba48 WebFrameLoaderClient::committedLoad(WebCore::DocumentLoader*, char const*, int) + 100
8   WebCore                         0x32ce2a48 WebCore::DocumentLoader::commitLoad(char const*, int) + 120
9   WebCore                         0x32ce29b4 WebCore::DocumentLoader::receivedData(char const*, int) + 72
10  WebCore                         0x32ce25da WebCore::ResourceLoader::didReceiveData(char const*, int, long long, bool) + 34
11  WebCore                         0x32ce2566 WebCore::MainResourceLoader::didReceiveData(char const*, int, long long, bool) + 474
12  WebCore                         0x32ce22b2 WebCore::ResourceLoader::didReceiveData(WebCore::ResourceHandle*, char const*, int, int) + 42
13  WebCore                         0x32ce2276 WebCore::ResourceHandle::handleDataArray(__CFArray const*) + 278
14  WebCore                         0x32ce2156 WebCore::didReceiveDataArray(_CFURLConnection*, __CFArray const*, void const*) + 34
15  CFNetwork                       0x370dd058 URLConnectionClient::_clientDidReceiveData(__CFArray const*, URLConnectionClient::ClientConnectionEventQueue*) + 220
16  CFNetwork                       0x370434b0 URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) + 436
17  CFNetwork                       0x37043592 URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) + 662
18  CFNetwork                       0x3704319c URLConnectionClient::processEvents() + 100
19  CFNetwork                       0x370430d2 MultiplexerSource::perform() + 150
20  CoreFoundation                  0x3738aacc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 8
21  CoreFoundation                  0x3738a298 __CFRunLoopDoSources0 + 208
22  CoreFoundation                  0x3738903e __CFRunLoopRun + 646
23  CoreFoundation                  0x3730c49e CFRunLoopRunSpecific + 294
24  CoreFoundation                  0x3730c366 CFRunLoopRunInMode + 98
25  WebCore                         0x32cb5c9c RunWebThread(void*) + 396
26  libsystem_c.dylib               0x33c2b72e _pthread_start + 314
27  libsystem_c.dylib               0x33c2b5e8 thread_start + 0

Thread 2 name:  WebThread
Thread 2 Crashed:
0   javascriptCore                  0x35653c7c WTF::fastFree(void*) + 80
1   WebCore                         0x32d064b4 WebCore::SegmentedString::prepend(WebCore::SegmentedSubstring const&) + 136
2   WebCore                         0x32d0640e WebCore::SegmentedString::prepend(WebCore::SegmentedString const&) + 66
3   WebCore                         0x32d047a8 WebCore::(anonymous namespace)::unconsumeCharacters(WebCore::SegmentedString&, WTF::Vector<unsigned short, 10ul> const&) + 188
4   WebCore                         0x32cf023e WebCore::consumeHTMLEntity(WebCore::SegmentedString&, WTF::Vector<unsigned short, 16ul>&, bool&, unsigned short) + 1850
5   WebCore                         0x32cef9e4 WebCore::HTMLTokenizer::processEntity(WebCore::SegmentedString&) + 40
6   WebCore                         0x32cbebe8 WebCore::HTMLTokenizer::nextToken(WebCore::SegmentedString&, WebCore::HTMLToken&) + 1232
7   WebCore                         0x32d03894 WebCore::HTMLPreloadScanner::scan() + 76
8   WebCore                         0x32cebc24 WebCore::HTMLDocumentParser::append(WebCore::SegmentedString const&) + 92
9   WebCore                         0x32cbce20 WebCore::DecodedDataDocumentParser::appendBytes(WebCore::DocumentWriter*, char const*, int, bool) + 200
10  WebCore                         0x32ceb8d0 WebCore::DocumentWriter::addData(char const*, int, bool) + 48
11  WebCore                         0x32ce5c3e WebCore::DocumentLoader::commitData(char const*, int) + 122
12  WebKit                          0x358cbc9a -[WebHTMLRepresentation receivedData:withDataSource:] + 158
13  WebKit                          0x358cbb10 -[WebDataSource(WebInternal) _receivedData:] + 164
14  WebKit                          0x358cba48 WebFrameLoaderClient::committedLoad(WebCore::DocumentLoader*, char const*, int) + 100
15  WebCore                         0x32ce2a48 WebCore::DocumentLoader::commitLoad(char const*, int) + 120
16  WebCore                         0x32ce29b4 WebCore::DocumentLoader::receivedData(char const*, int) + 72
17  WebCore                         0x32ce25da WebCore::ResourceLoader::didReceiveData(char const*, int, long long, bool) + 34
18  WebCore                         0x32ce2566 WebCore::MainResourceLoader::didReceiveData(char const*, int, long long, bool) + 474
19  WebCore                         0x32ce22b2 WebCore::ResourceLoader::didReceiveData(WebCore::ResourceHandle*, char const*, int, int) + 42
20  WebCore                         0x32ce2276 WebCore::ResourceHandle::handleDataArray(__CFArray const*) + 278
21  WebCore                         0x32ce2156 WebCore::didReceiveDataArray(_CFURLConnection*, __CFArray const*, void const*) + 34
22  CFNetwork                       0x370dd058 URLConnectionClient::_clientDidReceiveData(__CFArray const*, URLConnectionClient::ClientConnectionEventQueue*) + 220
23  CFNetwork                       0x370434b0 URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) + 436
24  CFNetwork                       0x3704319c URLConnectionClient::processEvents() + 100
25  CFNetwork                       0x370430d2 MultiplexerSource::perform() + 150
26  CoreFoundation                  0x3738aacc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 8
27  CoreFoundation                  0x3738a32e __CFRunLoopDoSources0 + 358
28  CoreFoundation                  0x3738903e __CFRunLoopRun + 646
29  CoreFoundation                  0x3730c49e CFRunLoopRunSpecific + 294
30  CoreFoundation                  0x3730c366 CFRunLoopRunInMode + 98
31  WebCore                         0x32cb5c9c RunWebThread(void*) + 396
32  libsystem_c.dylib               0x33c2b72e _pthread_start + 314
33  libsystem_c.dylib               0x33c2b5e8 thread_start + 0

【问题讨论】:

【参考方案1】:

WebThread 由 WebKit 管理,没有开发者拥有的代码在其中运行。我想知道,它可以在较新的 ios 固件上重现吗?你可以提交一份关于这个的雷达报告。

【讨论】:

我测试的开发环境是 Xcode 4.4.1 和 iOS 5.1.1。我刚刚在 iphone 3gs 上安装了 Xcode 4.5DP4 和 iOS6.0 beta 以查看那里是否发生崩溃。但是,对于 WebCore 崩溃的原因,是否有一个通用的答案?是因为网页本身的 HTML/JS 错误/不兼容吗?它是 WebCore 中的错误吗?我以前从未见过这些错误,所以我很迷茫...... 这是 WebKit 中的一个错误。你不应该对 WebKit 有那么大的“影响”让它崩溃。

以上是关于WebCore 的崩溃是不是意味着它必然与 UIWebView 相关?的主要内容,如果未能解决你的问题,请参考以下文章

WebCore bmalloc :: IsoAllocator在iOS 11.3中崩溃

WebCore WebCore::GraphicsContext3D::reshape(int, int)

[WebKit] JavaScriptCore解析--基础篇 JSC与WebCore

当需要设计模块化架构时,对象是否是现实的必然?

主动领取与被动分配

WebKit三件套:WebKit之WebCore篇