| Summary: | Memory leak issue for WKWebView:evaluateJavaScript | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Michael Kreitmann <Michael.kreitmann> | ||||
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> | ||||
| Status: | NEW --- | ||||||
| Severity: | Critical | CC: | achristensen, am, beidson, d4n3sz, eric.slosser, fpizlo, palaneappan.r, webkit-bug-importer | ||||
| Priority: | P2 | Keywords: | InRadar | ||||
| Version: | Safari 13 | ||||||
| Hardware: | iPhone / iPad | ||||||
| OS: | iOS 13 | ||||||
| Attachments: |
|
||||||
Unfortunately the problem is still present, so I have implemented a PoC to overcome this issue. https://github.com/Danesz/Sidewalk Sidewalk is available as a Swift package. Also a sample app with the proof of the leak: https://github.com/Danesz/SidewalkExample seems fixed in iOS 16.2 This issue still exists. I am able to reproduce the similar issue in safari browser. However, the memory issue doesn't occur in other web browsers though. |
Created attachment 407008 [details] Xcode project to reproduce the issue When calling evalueJavaScript function with a large String (i.e. a 100MB String) as show below, WebView will always hold a reference to this large string (allocating memory) and will not release the memory. Executing this code several times, will cause WebKit task to crash (due to memory issues) and will restart. __block NSString *script = [NSString stringWithFormat:@"//%@", [@"" stringByPaddingToLength:100*1024*1024 withString: @"?" startingAtIndex:0]]; [weakWebView evaluateJavaScript:script completionHandler:nil]; See attached Xcode project to reproduce the issue.