9

我试图UIWebView在我的 iPad 应用程序中包含一个基于浏览器的浏览器。这需要一些时间,这使得调试变得困难,但应用程序最终崩溃了,总是在同一个地方:WebThread,在 JavaScriptCoreWTF::StringImpl::hash()函数上。它产生EXC_BAD_ACCESS (SIGSEGV), KERN_INVALID_ADDRESS at 0x00000001.

UIWebView位于由另一个视图控制器(容器)以类似堆栈的方式管理的视图控制器内。我只在内存中保留了四个或更少的浏览器。

有关崩溃日志或可能导致崩溃的任何信息?

这是网络线程的崩溃日志:

Thread 2 name:  WebThread
Thread 2 Crashed:
0   JavaScriptCore                  0x32a97d46 WTF::StringImpl::hash() const + 42
1   JavaScriptCore                  0x32a97c6a WTF::HashTable<WTF::StringImpl*, WTF::StringImpl*, WTF::IdentityExtractor<WTF::StringImpl*>, WTF::StringHash, WTF::HashTraits<WTF::StringImpl*>, WTF::HashTraits<WTF::StringImpl*> >::lookupForWriting(WTF::StringImpl* const&) + 18
2   JavaScriptCore                  0x32a9b028 std::pair<WTF::HashTableIterator<WTF::StringImpl*, WTF::StringImpl*, WTF::IdentityExtractor<WTF::StringImpl*>, WTF::StringHash, WTF::HashTraits<WTF::StringImpl*>, WTF::HashTraits<WTF::StringImpl*> >, bool> WTF::HashTable<WTF::StringImpl*, WTF::StringImpl*, WTF::IdentityExtractor<WTF::StringImpl*>, WTF::StringHash, WTF::HashTraits<WTF::StringImpl*>, WTF::HashTraits<WTF::StringImpl*> >::add<WTF::StringImpl*, WTF::StringImpl*, WTF::IdentityHashTranslator<WTF::StringImpl*, WTF::StringImpl*, WTF::StringHash> >(WTF::StringImpl* const&, WTF::StringImpl* const&) + 448
3   JavaScriptCore                  0x32a9ae30 WTF::AtomicString::addSlowCase(WTF::StringImpl*) + 96
4   WebCore                         0x31bade0c WebCore::AtomicHTMLToken::initializeAttributes(WTF::Vector<WebCore::HTMLToken::Attribute, 10ul> const&) + 232
5   WebCore                         0x31b88076 WebCore::AtomicHTMLToken::AtomicHTMLToken(WebCore::HTMLToken&) + 302
6   WebCore                         0x31b87eae WebCore::HTMLTreeBuilder::constructTreeFromToken(WebCore::HTMLToken&) + 14
7   WebCore                         0x31b7d07e WebCore::HTMLDocumentParser::pumpTokenizer(WebCore::HTMLDocumentParser::SynchronousMode) + 150
8   WebCore                         0x31bee29a WebCore::HTMLDocumentParser::resumeParsingAfterScriptExecution() + 50
9   WebCore                         0x31bc87e6 WebCore::HTMLDocumentParser::notifyFinished(WebCore::CachedResource*) + 78
10  WebCore                         0x31bc7448 WebCore::CachedResource::checkNotify() + 40
11  WebCore                         0x31bc7308 WebCore::CachedScript::data(WTF::PassRefPtr<WebCore::SharedBuffer>, bool) + 84
12  WebCore                         0x31bc7240 WebCore::CachedResourceRequest::didFinishLoading(WebCore::SubresourceLoader*, double) + 120
13  WebCore                         0x31bc715e WebCore::SubresourceLoader::didFinishLoading(double) + 158
14  WebCore                         0x31bc58c2 _ZN7WebCoreL16didFinishLoadingEP16_CFURLConnectionPKv + 46
15  CFNetwork                       0x347737ee URLConnectionClient::_clientDidFinishLoading(URLConnectionClient::ClientConnectionEventQueue*) + 186
16  CFNetwork                       0x3476849e URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) + 418
17  CFNetwork                       0x3476819c URLConnectionClient::processEvents() + 100
18  CFNetwork                       0x347680d2 MultiplexerSource::perform() + 150
19  CoreFoundation                  0x313d2acc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 8
20  CoreFoundation                  0x313d2298 __CFRunLoopDoSources0 + 208
21  CoreFoundation                  0x313d103e __CFRunLoopRun + 646
22  CoreFoundation                  0x3135449e CFRunLoopRunSpecific + 294
23  CoreFoundation                  0x31354366 CFRunLoopRunInMode + 98
24  WebCore                         0x31b74c9c _ZL12RunWebThreadPv + 396
25  libsystem_c.dylib               0x33bca72e _pthread_start + 314
26  libsystem_c.dylib               0x33bca5e8 thread_start + 0
4

2 回答 2

11

我有同样的问题,花了一整天......有很多不同的 WebKit 错误,比如这些。最后,我明白了:这是一个多线程问题!我从线程 1 创建了 WebView,然后尝试通过线程 2 中的 JS 函数修改其内容...

简单的performSelectorOnMainThread:withObject:waitUntilDone:的解决了问题!

也许这会对某人有所帮助。

于 2013-03-20T12:52:46.450 回答
0

正如崩溃日志所暗示的那样,它看起来可能是与 JavaScript 相关的问题。我假设您正在加载的页面上有 JavaScript?出于兴趣,网页在 Mobile Safari 中是否运行良好 - 是否只是在 UIWebView 中出现问题?

如果您无法修改 JS,或者网页似乎在其他移动/桌面浏览器或设备上运行良好,我建议向 Apple 提交错误以及用于重现问题的 JavaScript。

于 2012-08-12T11:22:25.907 回答