#iOS問題記錄#WKWebView 閃退異常
異常描述:
pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
問題描述:
將UIWebView 轉(zhuǎn)成WKWebview后所坯,在UMeng的錯(cuò)誤里偶爾會(huì)出現(xiàn)幾次報(bào)錯(cuò)欺旧,排查后眯分,定位到WKWebview相關(guān)祥款;
但問題只會(huì)出現(xiàn)在iOS10.0以下的系統(tǒng)。
在模擬器上使用8.1的系統(tǒng)調(diào)試確實(shí)會(huì)有這種異常盗迟,
使用malloc_error_break定位劫侧,也只能定位到內(nèi)存釋放時(shí)出棧異常谋国,沒辦法繼續(xù)調(diào)試。
原因:
通過排除法号阿,發(fā)現(xiàn)只要不監(jiān)聽wkwebview.scrollview的delegate,就不會(huì)異常并鸵;
想起scrollview是strong引用:
@property (nonatomic, readonly, strong) UIScrollView *scrollView;
解決方法:
將delegate設(shè)置為nil:
- (void) dealloc
{
if(_mWebViewReport)
{
_mWebViewReport.scrollView.delegate=nil;
}
}