Bug 252812 - Memory Leak for WKWebView:evaluateJavaScript:completionHandler
Summary: Memory Leak for WKWebView:evaluateJavaScript:completionHandler
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: iPhone / iPad iOS 16
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-02-23 05:58 PST by Paula
Modified: 2023-02-27 11:25 PST (History)
3 users (show)

See Also:


Attachments
Memory Graph Screenshot (165.08 KB, image/png)
2023-02-23 05:58 PST, Paula
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paula 2023-02-23 05:58:49 PST
Created attachment 465132 [details]
Memory Graph Screenshot

Memory leaks (Malloc 32 Bytes x 4) when calling WKWebView.evaluateJavaScript passing a completion handler. 

Code example: 

extension ViewController: WKNavigationDelegate {
    func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
        webView.evaluateJavaScript("document.documentElement.scrollHeight", completionHandler: { (height, error) in
            self.webViewHeightConstraint?.constant = height as! CGFloat
        })
    }
}

On the memory graph it is possible to see that it is on JavaScriptCore.

Tested on iOS 16.2 and 16.0.1.
Comment 1 Radar WebKit Bug Importer 2023-02-27 11:25:19 PST
<rdar://problem/105986674>