Ios UIWebView在资源加载时崩溃应用程序

Ios UIWebView在资源加载时崩溃应用程序,ios,uiwebview,Ios,Uiwebview,我知道这可能是一个漫长的过程,但我看到了这场野外崩盘(无法重新制作)。我不明白为什么会这样。我相信我看到的是我的UIWebView试图调用它的委托来加载资源,但发现委托被解除分配。但是,我的应用程序没有取消分配UIWebView,只是出于各种原因取消了UIWebView,我的WebViewDelegate也没有实现webView:identifierForInitialRequest:fromDataSource:方法。我已经把下面的崩溃时间缩短到我认为令人不快的程度,如果有人能给我指出正确的方

我知道这可能是一个漫长的过程,但我看到了这场野外崩盘(无法重新制作)。我不明白为什么会这样。我相信我看到的是我的UIWebView试图调用它的委托来加载资源,但发现委托被解除分配。但是,我的应用程序没有取消分配UIWebView,只是出于各种原因取消了UIWebView,我的WebViewDelegate也没有实现
webView:identifierForInitialRequest:fromDataSource:
方法。我已经把下面的崩溃时间缩短到我认为令人不快的程度,如果有人能给我指出正确的方向,我会很高兴的

Thread 0 Crashed:
0   libobjc.A.dylib                0x00000001926abbd0 objc_msgSend + 16
1   UIKit                          0x0000000186a10b78 -[UIWebView webView:identifierForInitialRequest:fromDataSource:] + 88
2   CoreFoundation                 0x0000000182067dec __invoking___ + 140
3   CoreFoundation                 0x0000000181f66658 -[NSInvocation invoke] + 292
4   CoreFoundation                 0x0000000181f6b1ec -[NSInvocation invokeWithTarget:] + 64
5   WebKitLegacy                   0x00000001907e5750 -[_WebSafeForwarder forwardInvocation:] + 168
6   CoreFoundation                 0x0000000182065c5c ___forwarding___ + 436
7   CoreFoundation                 0x0000000181f6b088 _CF_forwarding_prep_0 + 88
8   CoreFoundation                 0x0000000182067dec __invoking___ + 140
9   CoreFoundation                 0x0000000181f66658 -[NSInvocation invoke] + 292
10  WebCore                        0x000000018f99a8f0 _ZL20HandleDelegateSourcePv + 116
11  CoreFoundation                 0x000000018201a320 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 20
12  CoreFoundation                 0x00000001820195c4 __CFRunLoopDoSources0 + 260
13  CoreFoundation                 0x0000000182017674        0x181f3c000 + 708
14  CoreFoundation                 0x0000000181f45660 CFRunLoopRunSpecific + 392
15  GraphicsServices               0x000000018b07f5a0 GSEventRunModal + 164
16  UIKit                          0x000000018684a980 UIApplicationMain + 1484
17  IMNOTTELLING                   0x0000000100195fd8 main (main.m:14)
18  libdyld.dylib                  0x0000000192d06a04 start + 0

Thread 4:
0   libsystem_kernel.dylib         0x0000000192e1f078 __psynch_cvwait + 8
1   WebCore                        0x000000018f97fb98 _ZL19SendDelegateMessageP12NSInvocation + 612
2   WebKitLegacy                   0x000000019081aec0 _Z24CallResourceLoadDelegatePFP11objc_objectS0_P13objc_selectorzEP7WebViewS1_S0_S0_ + 152
3   WebKitLegacy                   0x00000001907e2364 _ZN20WebFrameLoaderClient32assignIdentifierToInitialRequestEmPN7WebCore14DocumentLoaderERKNS0_15ResourceRequestE + 316
4   WebCore                        0x000000018f8ef2d4 _ZN7WebCore14ResourceLoader15willSendRequestERNS_15ResourceRequestERKNS_16ResourceResponseE + 156
5   WebCore                        0x000000018f8ef1b8 _ZN7WebCore17SubresourceLoader15willSendRequestERNS_15ResourceRequestERKNS_16ResourceResponseE + 336
6   WebCore                        0x000000018f8eeec4 _ZN7WebCore14ResourceLoader4initERKNS_15ResourceRequestE + 308
7   WebCore                        0x000000018f8eebc0 _ZN7WebCore17SubresourceLoader12startLoadingEv + 52
8   WebCore                        0x000000018f8eeb0c _ZN7WebCore21ResourceLoadScheduler20servePendingRequestsEPNS0_15HostInformationENS_20ResourceLoadPriorityE + 520
9   WebCore                        0x000000018f8edf54 _ZN7WebCore21ResourceLoadScheduler23scheduleSubresourceLoadEPNS_5FrameEPNS_14CachedResourceERKNS_15ResourceRequestENS_20ResourceLoadPriorityERKNS_21ResourceLoaderOptionsE + 80
10  WebCore                        0x000000018f8eca84 _ZN7WebCore14CachedResource4loadEPNS_20CachedResourceLoaderERKNS_21ResourceLoaderOptionsE + 1176
11  WebCore                        0x000000018f8ea558 _ZN7WebCore20CachedResourceLoader15requestResourceENS_14CachedResource4TypeERNS_21CachedResourceRequestE + 1236
12  WebCore                        0x000000018faebbf8 _ZN7WebCore20CachedResourceLoader18requestRawResourceERNS_21CachedResourceRequestE + 40
13  WebCore                        0x000000018faeb74c _ZN7WebCore24DocumentThreadableLoader11loadRequestERKNS_15ResourceRequestENS_19SecurityCheckPolicyE + 248
14  WebCore                        0x000000018fc9f5fc _ZN7WebCore24DocumentThreadableLoader34makeSimpleCrossOriginAccessRequestERKNS_15ResourceRequestE + 124
15  WebCore                        0x000000018fc9f448 _ZN7WebCore24DocumentThreadableLoader28makeCrossOriginAccessRequestERKNS_15ResourceRequestE + 256
16  WebCore                        0x000000018fc9f288 _ZN7WebCore24DocumentThreadableLoaderC2ERNS_8DocumentERNS_22ThreadableLoaderClientENS0_16BlockingBehaviorERKNS_15ResourceRequestERKNS_23ThreadableLoaderOptionsE + 504
17  WebCore                        0x000000018fc9f044 _ZN7WebCore24DocumentThreadableLoader6createERNS_8DocumentERNS_22ThreadableLoaderClientERKNS_15ResourceRequestERKNS_23ThreadableLoaderOptionsE + 68
18  WebCore                        0x000000018faeb624 _ZN7WebCore16ThreadableLoader6createEPNS_22ScriptExecutionContextEPNS_22ThreadableLoaderClientERKNS_15ResourceRequestERKNS_23ThreadableLoaderOptionsE + 156
19  WebCore                        0x000000018faeb24c _ZN7WebCore14XMLHttpRequest13createRequestERi + 1132
20  WebCore                        0x000000018faeadc0 _ZN7WebCore14XMLHttpRequest4sendERKN3WTF6StringERi + 832
21  WebCore                        0x000000018faea61c _ZN7WebCore16JSXMLHttpRequest4sendEPN3JSC9ExecStateE + 252
22  JavaScriptCore                 0x000000018384262c        0x1834ac000 + 26140
23  JavaScriptCore                 0x0000000183842058 llint_entry + 24648
24  JavaScriptCore                 0x0000000183842058 llint_entry + 24648
25  JavaScriptCore                 0x0000000183841ff4        0x1834ac000 + 24548
26  JavaScriptCore                 0x0000000183841ff4        0x1834ac000 + 24548
27  JavaScriptCore                 0x0000000183841ff4        0x1834ac000 + 24548
28  JavaScriptCore                 0x0000000183841ff4        0x1834ac000 + 24548
29  JavaScriptCore                 0x0000000183842058 llint_entry + 24648
30  JavaScriptCore                 0x000000018383bdf0 callToJavaScript + 304
31  JavaScriptCore                 0x00000001837aa454 _ZN3JSC7JITCode7executeEPNS_2VMEPNS_14ProtoCallFrameE + 44
32  JavaScriptCore                 0x0000000183515554 _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 416
33  JavaScriptCore                 0x00000001836414a4 _ZN3JSC4callEPNS_9ExecStateENS_7JSValueENS_8CallTypeERKNS_8CallDataES2_RKNS_7ArgListEPS2_ + 88
34  WebCore                        0x000000018f8de73c _ZN7WebCore15ScheduledAction24executeFunctionInContextEPN3JSC14JSGlobalObjectENS1_7JSValueEPNS_22ScriptExecutionContextE + 488
35  WebCore                        0x000000018f8de2d0 _ZN7WebCore15ScheduledAction7executeEPNS_8DocumentE + 140
36  WebCore                        0x000000018f8dda74 _ZN7WebCore8DOMTimer5firedEv + 504
37  WebCore                        0x000000018f8dd4dc _ZN7WebCore12ThreadTimers24sharedTimerFiredInternalEv + 144
38  WebCore                        0x000000018f8dd420 _ZN7WebCoreL10timerFiredEP16__CFRunLoopTimerPv + 32
39  CoreFoundation                 0x000000018201a20c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 24
40  CoreFoundation                 0x0000000182019ebc __CFRunLoopDoTimer + 884
41  CoreFoundation                 0x0000000182017908        0x181f3c000 + 1368
42  CoreFoundation                 0x0000000181f45660 CFRunLoopRunSpecific + 392
43  WebCore                        0x000000018f964554 _ZL12RunWebThreadPv + 464
44  libsystem_pthread.dylib        0x0000000192ebbe7c _pthread_body + 160
45  libsystem_pthread.dylib        0x0000000192ebbdd8 _pthread_start + 156
46  libsystem_pthread.dylib        0x0000000192eb8fac thread_start + 0

在我找到原因之前,我也有过一段时间的问题。我一直在
UIWebView
上调用
removeFromSuperview
,其中包含我们的
UIWebView
,而没有
nil
显示
UIWebView
的代表。因此,我猜想
UIWebView
必须始终具有活动视图层次结构,除非其委托是
nil

目标-C

// Make sure this code is called before `removeFromSuperview`
webView.delegate = nil;
[webView loadHTMLString: @"about:blank" baseURL: nil];
[webView stopLoading];
迅捷的


在我找到原因之前,我也有过一段时间的问题。我一直在
UIWebView
上调用
removeFromSuperview
,其中包含我们的
UIWebView
,而没有
nil
显示
UIWebView
的代表。因此,我猜想
UIWebView
必须始终具有活动视图层次结构,除非其委托是
nil

目标-C

// Make sure this code is called before `removeFromSuperview`
webView.delegate = nil;
[webView loadHTMLString: @"about:blank" baseURL: nil];
[webView stopLoading];
迅捷的


你把它修好了吗?我也收到过类似的崩溃报告。不确定我们是否真的解决了根本原因,但我们发现一些web视图没有正确保留委托,因此一些javascript回调试图通过调用并崩溃。您解决了这个问题吗?我收到过类似的坠机报告不确定我们是否真的解决了根本原因,但我们发现一些web视图没有正确保留代理,因此一些javascript回调试图调用并崩溃。更新:苹果拒绝任何仍然使用
UIWebView
的应用程序-因此请根据需要转到
WKWebView
。更新:苹果拒绝任何仍然使用的应用程序
UIWebView
-因此请根据需要转到
WKWebView