webview动画引发的Crash问题

    在执行自动化测试过程中,不规律的出现了几次Crash,无法找到固定的重现步骤,Crash栈如下:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000008
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib               	0x390b15b0 objc_msgSend + 16
1   UIKit                         	0x33289182 -[_UIWebViewScrollViewDelegateForwarder forwardInvocation:] + 138
2   CoreFoundation                	0x31218616 ___forwarding___ + 622
3   CoreFoundation                	0x3116ff64 _CF_forwarding_prep_0 + 20
4   UIKit                         	0x330d40c2 -[UIScrollView _getDelegateZoomView] + 98
5   UIKit                         	0x330d3fc0 -[UIScrollView _zoomScaleFromPresentationLayer:] + 24
6   UIKit                         	0x330d9fec -[UIWebDocumentView _zoomedDocumentScale] + 56
7   UIKit                         	0x330d6ae8 -[UIWebDocumentView _layoutRectForFixedPositionObjects] + 100
8   UIKit                         	0x3327b292 -[UIWebDocumentView _updateFixedPositionedObjectsLayoutRectUsingWebThread:synchronize:] + 38
9   UIKit                         	0x330dc6d4 -[UIWebDocumentView _updateFixedPositioningObjectsLayoutAfterScroll] + 24
10  UIKit                         	0x330dc6b0 -[UIWebBrowserView _updateFixedPositioningObjectsLayoutAfterScroll] + 52
11  UIKit                         	0x330dc566 -[UIWebDocumentView _restoreScrollPointForce:] + 502
12  UIKit                         	0x330dc25c -[UIWebDocumentView _resetForNewPage] + 408
13  UIKit                         	0x330a84c4 -[UIWebDocumentView layoutSubviews] + 72
14  UIKit                         	0x330217fe -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 254
15  QuartzCore                    	0x32dcbd86 -[CALayer layoutSublayers] + 210
16  QuartzCore                    	0x32dcb924 CA::Layer::layout_if_needed(CA::Transaction*) + 456
17  QuartzCore                    	0x32dcc858 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 12
18  QuartzCore                    	0x32dcc23e CA::Context::commit_transaction(CA::Transaction*) + 234
19  QuartzCore                    	0x32dcc04c CA::Transaction::commit() + 312
20  UIKit                         	0x330278e6 _afterCACommitHandler + 122
21  CoreFoundation                	0x311eb6ca __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 18
22  CoreFoundation                	0x311e99bc __CFRunLoopDoObservers + 272
23  CoreFoundation                	0x311e9d12 __CFRunLoopRun + 738
24  CoreFoundation                	0x3115ceb8 CFRunLoopRunSpecific + 352
25  CoreFoundation                	0x3115cd44 CFRunLoopRunInMode + 100
26  GraphicsServices              	0x34d262e6 GSEventRunModal + 70
27  UIKit                         	0x330722fc UIApplicationMain + 1116
28  MyApp                     	        0x0000fc60 main (main.m:15)
29  libdyld.dylib                 	0x394edb1c start + 0

  Crash栈咋一看,挂在系统的API调用上,再仔细看一下报EXC_BAD_ACESS错误,应该是对象被释放后导致了野指针调用问题。仔细查看Apps中调用到Webview的地方发现,使用方法没什么问题。网上搜索了一下发现,该问题可能是由于webview在动画中,持有者(VC)已经被释放导致的。

  解决办法:在所有持有Webview的对象释放前都添加了Webview的delegate置空操作。

  在自动化测试中tableview,scrollview也遇到了Webview相似的问题,因此就在程序中相关地方都做了保护处理,之后自动化测试中该类问题没有再出现过。

  一点感想:拿到Crash栈,一看是挂在系统调用,估计就不想花时间解决了。有时候坚持一下,多看一会儿,多想一下,尝试去Google上搜一下Crash信息中的一些字段,或许别人也有遇到过相同或者相似的问题,说不定得到启发从而解决了一个看似没法解决的问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值