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

时间:2015-12-22 00:01:37

标签: ios 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

1 个答案:

答案 0 :(得分:3)

在我找到原因之前,我已经暂时解决了这个问题。我一直在removeFromSuperview上调用UIView,其中UIWebView包含nil UIWebView UIWebView代表。所以我想nil必须始终有一个活动的视图层次结构,除非它的委托是// Make sure this code is called before `removeFromSuperview` webView.delegate = nil; [webView loadHTMLString: @"about:blank" baseURL: nil]; [webView stopLoading];

目标-C

// Make sure this code is called before `removeFromSuperview`
webView.delegate = nil
webView.loadHTMLString("about:blank", baseURL: nil)
webView.stopLoading()

夫特

{
    "cmd": ["cmd", "/e:on", "/v:on", "/k", "ipsxe-comp-vars intel64 vs2013 && ifort ${file}"],  
    "file_regex": "^.*\\\\([0-9A-Za-z_]+\\.[A-Za-z0-9]+)\\(([0-9]+)\\):[ ]+error[ ]+#([0-9]+):[ ]+(.*)$",  
    "working_dir":"${file_path}",   
    "selector":"source.f ,source.for ,source.ftn ,source.f90 ,source.fpp ,source.i ,source.i90",
    "encoding":"cp936",
    "path":"C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2017.4.210\\windows\\bin;${path}",
    "variants":
      [  
           {  
              "name": "Run", 
              "cmd": ["cmd", "/e:on", "/v:on", "/c", "ipsxe-comp-vars intel64 vs2013 && ifort ${file} && ${file_base_name}"] 
          }  
     ]  

}