webview动画引发的Crash问题

来源:互联网 发布:东阳司法拍卖网淘宝网 编辑:程序博客网 时间:2024/06/05 15:14

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

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)Exception Codes: KERN_INVALID_ADDRESS at 0x00000008Crashed Thread:  0Thread 0 name:  Dispatch queue: com.apple.main-threadThread 0 Crashed:0   libobjc.A.dylib               0x390b15b0 objc_msgSend + 161   UIKit                         0x33289182 -[_UIWebViewScrollViewDelegateForwarder forwardInvocation:] + 1382   CoreFoundation                0x31218616 ___forwarding___ + 6223   CoreFoundation                0x3116ff64 _CF_forwarding_prep_0 + 204   UIKit                         0x330d40c2 -[UIScrollView _getDelegateZoomView] + 985   UIKit                         0x330d3fc0 -[UIScrollView _zoomScaleFromPresentationLayer:] + 246   UIKit                         0x330d9fec -[UIWebDocumentView _zoomedDocumentScale] + 567   UIKit                         0x330d6ae8 -[UIWebDocumentView _layoutRectForFixedPositionObjects] + 1008   UIKit                         0x3327b292 -[UIWebDocumentView _updateFixedPositionedObjectsLayoutRectUsingWebThread:synchronize:] + 389   UIKit                         0x330dc6d4 -[UIWebDocumentView _updateFixedPositioningObjectsLayoutAfterScroll] + 2410  UIKit                         0x330dc6b0 -[UIWebBrowserView _updateFixedPositioningObjectsLayoutAfterScroll] + 5211  UIKit                         0x330dc566 -[UIWebDocumentView _restoreScrollPointForce:] + 50212  UIKit                         0x330dc25c -[UIWebDocumentView _resetForNewPage] + 40813  UIKit                         0x330a84c4 -[UIWebDocumentView layoutSubviews] + 7214  UIKit                         0x330217fe -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 25415  QuartzCore                    0x32dcbd86 -[CALayer layoutSublayers] + 21016  QuartzCore                    0x32dcb924 CA::Layer::layout_if_needed(CA::Transaction*) + 45617  QuartzCore                    0x32dcc858 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 1218  QuartzCore                    0x32dcc23e CA::Context::commit_transaction(CA::Transaction*) + 23419  QuartzCore                    0x32dcc04c CA::Transaction::commit() + 31220  UIKit                         0x330278e6 _afterCACommitHandler + 12221  CoreFoundation                0x311eb6ca __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 1822  CoreFoundation                0x311e99bc __CFRunLoopDoObservers + 27223  CoreFoundation                0x311e9d12 __CFRunLoopRun + 73824  CoreFoundation                0x3115ceb8 CFRunLoopRunSpecific + 35225  CoreFoundation                0x3115cd44 CFRunLoopRunInMode + 10026  GraphicsServices              0x34d262e6 GSEventRunModal + 7027  UIKit                         0x330722fc UIApplicationMain + 111628  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
原创粉丝点击