String UIWebView从HTML加载链接时崩溃

String UIWebView从HTML加载链接时崩溃,string,jquery-mobile,uiwebview,crash,String,Jquery Mobile,Uiwebview,Crash,如果我在包含外部链接的UIWebView中调用loadHTMLString,然后再次尝试加载HtmlString,则会崩溃 HTML的加载方式如下: NSURL *url = [[NSBundle mainBundle] URLForResource:@"help" withExtension:@"html"]; NSString *text = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding

如果我在包含外部链接的UIWebView中调用loadHTMLString,然后再次尝试加载HtmlString,则会崩溃

HTML的加载方式如下:

    NSURL *url = [[NSBundle mainBundle] URLForResource:@"help" withExtension:@"html"];
    NSString *text = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];

    [[self webView] loadHTMLString:text baseURL:nil];
help.html可以包含以下链接:

如果我点击链接,它将加载页面。但我在导航栏上有一个“主页”按钮,再次调用上述代码(loadHTMLString),这会使应用程序崩溃

在查看外部链接后,有没有办法“欺骗”UIWebView再次加载HTML字符串

参考资料:

***由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“***setObjectForKey:密钥不能为零”
#0 0x906b29c6在线程终止()
#pthread_kill()中的1 0x9ca6ff78
#2 0x0399957b处于中止状态()
#3 0x03b19f7b在中止消息()中
#默认情况下为4 0x03b17a25_terminate()()
#5 0x035620c1位于_objc_terminate()()
#安全处理器中的6 0x03b17a65调用者(无效(*)()
#std::terminate()中的7 0x03b17acd()
#8 0x03b18bc2英寸cxa掷程()
#9 0x03561f89在objc_异常_抛出()中
#10 0x03fd50de在-[\uu NSDictionaryM setObject:forKey:]()
#11 0x03d485ce in-[WebHistory Private Visited URL:带标题:increaseVisitCount:]()
#12 0x03d4a693 in-[WebHistory(WebInternal)\访问URL:withTitle:method:wasFailure:increaseVisitCount:()
#WebFrameLoaderClient::updateGlobalHistory()中的13 0x03d394b5()
#WebCore::HistoryController::replaceState中的14 0x04db0747(WTF::PassRefPtr,WTF::String const&,WTF::String const&)()
#WebCore::History::stateObjectAdded中的15 0x04dad610(WTF::PassRefPtr,WTF::String const&,WTF::String const&,WebCore::History::StateObjectType,int&)()
#WebCore::JSHistory::replaceState(JSC::ExecState*)()中的16 0x0508041a
#WebCore::jsHistoryPrototypeFunctionReplaceState(JSC::ExecState*)中的17 0x0507ec49()
#0x0d892daf中的18 0x0d892daf()
#JSC::解释器::executeCall(JSC::ExecState*,JSC::JSObject*,JSC::CallType,JSC::CallData常量&,JSC::JSValue,JSC::ArgList常量&)中的19 0x08052e11()
#JSC::call中的20 0x07fabfc3(JSC::ExecState*,JSC::JSValue,JSC::CallType,JSC::CallData常量&,JSC::JSValue,JSC::ArgList常量&)()
#21 WebCore::JSMainThreadExecState::call中的0x04f91d34(JSC::ExecState*,JSC::JSValue,JSC::CallType,JSC::CallData常量&,JSC::JSC::ArgList常量&)()
#22 WebCore::JSEventListener::handleEvent(WebCore::ScriptExecutionContext*,WebCore::Event*)中的0x05064d15()
#23 WebCore::EventTarget::fireEventListeners中的0x04ce9eac(WebCore::Event*,WebCore::EventTargetData*,WTF::Vector&)()
#WebCore::EventTarget::fireEventListeners(WebCore::Event*)()中的24 0x04ce9c76
#WebCore::Node::handleLocalEvents(WebCore::Event*)()中的25 0x05333ce9
#WebCore::EventDispatcher::dispatchEvent(WTF::PassRefPtr)()中的26 0x04cd0419
#WebCore::EventDispatchMediator::dispatchEvent(WebCore::EventDispatcher*)常量中的27 0x04cd16da
#WebCore::EventDispatcher::dispatchEvent中的28 0x04ccf72e(WebCore::Node*,WTF::PassRefPtr)()
#WebCore::Node::dispatchEvent(WTF::PassRefPtr)()中的29 0x05333eaa
#WebCore::Document::finishedParsing()中的30 0x04bf85ad()
#31 WebCore::HTMLTreeBuilder::finished()中的0x04e570ad()
#WebCore::HTMLDocumentParser::prepareToStopParsing()中的32 0x04dd4a9b()
#WebCore::DocumentWriter::end()中的33 0x04c16a14()
#WebCore::DocumentLoader::finishedLoading()中的34 0x04c092a3()
#WebCore中的35 0x052f6c22::MainResourceLoader::didFinishLoading(双精度)()
#WebCore::MainResourceLoader::continueAfterContentPolicy(WebCore::PolicyAction,WebCore::ResourceResponse常量)()中的36 0x052f5c58
#37 WebCore::MainResourceLoader::didReceiveResponse中的0x052f650e(WebCore::ResourceResponse常量)()
#38 WebCore::MainResourceLoader::handleDataLoadNow(WebCore::Timer*)中的0x052f4a58()
#39 WebCore::Timer::fired()中的0x052f8016()
#WebCore::ThreadTimers::sharedTimerFiredInternal()中的40 0x056e415c()
#WebCore::ThreadTimers::sharedTimerFired()中的41 0x056e4036()
#WebCore中的42 0x05531c50::timerFired(uu CFRunLoopTimer*,void*)()
#43 0x03f11376 in uuu CFRUNLOOP正在调用u OUT u到u计时器u回调函数uu()
#44 0x03f10e06英寸\uuu CFRunLoopDoTimer()
#45 0x03ef8a82英寸\uuuu CFRunLoopRun()
#CFRunLoopRunSpecific()中的46 0x03ef7f44
#CFRunLoopRunInMode()中的47 0x03ef7e1b
#RunWebThread(void*)()中的48 0x05723c50
#49 0x9ca6ded9在线程启动()中

这似乎是UIWebview上的一个bug。即使内容不存在或出现HTML错误,UIWebview也不应该崩溃。提交一个bug

是的,我认为这是一个bug,因为我每次都可以复制它。额外的测试表明该问题与jQuery mobile有关。如果我使用带有链接的简单HTML文件,它不会崩溃。我计划明天再查一些。
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: key cannot be nil'

#0  0x906b29c6 in __pthread_kill ()
#1  0x9ca6ff78 in pthread_kill ()
#2  0x0399957b in abort ()
#3  0x03b19f7b in abort_message ()
#4  0x03b17a25 in default_terminate() ()
#5  0x035620c1 in _objc_terminate() ()
#6  0x03b17a65 in safe_handler_caller(void (*)()) ()
#7  0x03b17acd in std::terminate() ()
#8  0x03b18bc2 in __cxa_throw ()
#9  0x03561f89 in objc_exception_throw ()
#10 0x03fd50de in -[__NSDictionaryM setObject:forKey:] ()
#11 0x03d485ce in -[WebHistoryPrivate visitedURL:withTitle:increaseVisitCount:] ()
#12 0x03d4a693 in -[WebHistory(WebInternal) _visitedURL:withTitle:method:wasFailure:increaseVisitCount:] ()
#13 0x03d394b5 in WebFrameLoaderClient::updateGlobalHistory() ()
#14 0x04db0747 in WebCore::HistoryController::replaceState(WTF::PassRefPtr<WebCore::SerializedScriptValue>, WTF::String const&, WTF::String const&) ()
#15 0x04dad610 in WebCore::History::stateObjectAdded(WTF::PassRefPtr<WebCore::SerializedScriptValue>, WTF::String const&, WTF::String const&, WebCore::History::StateObjectType, int&) ()
#16 0x0508041a in WebCore::JSHistory::replaceState(JSC::ExecState*) ()
#17 0x0507ec49 in WebCore::jsHistoryPrototypeFunctionReplaceState(JSC::ExecState*) ()
#18 0x0d892daf in 0x0d892daf ()
#19 0x08052e11 in JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) ()
#20 0x07fabfc3 in JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) ()
#21 0x04f91d34 in WebCore::JSMainThreadExecState::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) ()
#22 0x05064d15 in WebCore::JSEventListener::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) ()
#23 0x04ce9eac in WebCore::EventTarget::fireEventListeners(WebCore::Event*, WebCore::EventTargetData*, WTF::Vector<WebCore::RegisteredEventListener, 1ul>&) ()
#24 0x04ce9c76 in WebCore::EventTarget::fireEventListeners(WebCore::Event*) ()
#25 0x05333ce9 in WebCore::Node::handleLocalEvents(WebCore::Event*) ()
#26 0x04cd0419 in WebCore::EventDispatcher::dispatchEvent(WTF::PassRefPtr<WebCore::Event>) ()
#27 0x04cd16da in WebCore::EventDispatchMediator::dispatchEvent(WebCore::EventDispatcher*) const ()
#28 0x04ccf72e in WebCore::EventDispatcher::dispatchEvent(WebCore::Node*, WTF::PassRefPtr<WebCore::EventDispatchMediator>) ()
#29 0x05333eaa in WebCore::Node::dispatchEvent(WTF::PassRefPtr<WebCore::Event>) ()
#30 0x04bf85ad in WebCore::Document::finishedParsing() ()
#31 0x04e570ad in WebCore::HTMLTreeBuilder::finished() ()
#32 0x04dd4a9b in WebCore::HTMLDocumentParser::prepareToStopParsing() ()
#33 0x04c16a14 in WebCore::DocumentWriter::end() ()
#34 0x04c092a3 in WebCore::DocumentLoader::finishedLoading() ()
#35 0x052f6c22 in WebCore::MainResourceLoader::didFinishLoading(double) ()
#36 0x052f5c58 in WebCore::MainResourceLoader::continueAfterContentPolicy(WebCore::PolicyAction, WebCore::ResourceResponse const&) ()
#37 0x052f650e in WebCore::MainResourceLoader::didReceiveResponse(WebCore::ResourceResponse const&) ()
#38 0x052f4a58 in WebCore::MainResourceLoader::handleDataLoadNow(WebCore::Timer<WebCore::MainResourceLoader>*) ()
#39 0x052f8016 in WebCore::Timer<WebCore::MainResourceLoader>::fired() ()
#40 0x056e415c in WebCore::ThreadTimers::sharedTimerFiredInternal() ()
#41 0x056e4036 in WebCore::ThreadTimers::sharedTimerFired() ()
#42 0x05531c50 in WebCore::timerFired(__CFRunLoopTimer*, void*) ()
#43 0x03f11376 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#44 0x03f10e06 in __CFRunLoopDoTimer ()
#45 0x03ef8a82 in __CFRunLoopRun ()
#46 0x03ef7f44 in CFRunLoopRunSpecific ()
#47 0x03ef7e1b in CFRunLoopRunInMode ()
#48 0x05723c50 in RunWebThread(void*) ()
#49 0x9ca6ded9 in _pthread_start ()