webview - iOS UIWebView leaked -
class myviewcontroller: uiviewcontroller { @iboutlet weak var webview: uiwebview? override func viewdidload() { super.viewdidload() let url = nsurl(string: urlstring) let request = nsurlrequest(url: url!) svprogresshud.show() webview?.loadrequest(request) webview?.scrollview.header = mjrefreshnormalheader(refreshingblock: { [weak self] in if let strongself = self { strongself.webview?.reload() }}) } override func viewdiddisappear(animated: bool) { super.viewdiddisappear(animated) svprogresshud.dismiss() } } extension myviewcontroller: uiwebviewdelegate { func webviewdidfinishload(webview: uiwebview) { webview.scrollview.header.endrefreshing() svprogresshud.dismiss() } func webview(webview: uiwebview, didfailloadwitherror error: nserror?) { webview.scrollview.header.endrefreshing() svprogresshud.dismiss() } }
the view controller pushed navigation controller, when pop it, got leaks. in instrument.leak saw these.
#
leaked object # address size responsible library responsible frame nsmutablearray 1 0x137a6ddb0 48 bytes uikit -[_uikeyboardtextselectiongesturecontroller init] _uikeyboardtextselectioncontroller 1 0x137a6e800 96 bytes uikit -[uiwebselectionassistant addnoneditableforcetextselectiongesturerecognizerstoview:] _uikeyboardbasednoneditabletextselectiongesturecontroller 1 0x137a6dcd0 160 bytes uikit -[uiwebselectionassistant addnoneditableforcetextselectiongesturerecognizerstoview:]
#
i'm sure webview, myviewcontroller delayed, when pop myviewcontroller, 4m increased , not release. please , thanks.
list item
according an answer posted here, there workaround if set configuration.selectiongranularity
wkselectiongranularitycharacter
, leaks stop:
let config = wkwebviewconfiguration() config.selectiongranularity = .character //wkselectiongranularitycharacter let mywebview = wkwebview(frame: frame, configuration: config)
this worked me, then, when selecting text, there no selection rectangle in webview. may or may not viable workaround in case.
edit noticed question uiwebview, not wkwebview. doesn't can set on uiwebview. i'll leave answer since wkwebview folks googling memory leak find thread...
Comments
Post a Comment