RESOLVED FIXED 140203
WKWebView crashes on deallocation
https://bugs.webkit.org/show_bug.cgi?id=140203
Summary WKWebView crashes on deallocation
Eugene But
Reported 2015-01-07 14:00:48 PST
Created attachment 244195 [details] Test App Summary: [Chrome] WKWebView crashes on deallocation if it has pending JavaScript evaluation. Steps to Reproduce: 1. Unarchive WKWebView.zip 2. Build and run test project on device or simulator Expected Results: "No error" should appear in console Actual Results: App crashes
Attachments
Test App (18.97 KB, application/zip)
2015-01-07 14:00 PST, Eugene But
no flags
Crash Log (29.03 KB, text/plain)
2015-01-07 14:01 PST, Eugene But
no flags
Patch (10.81 KB, patch)
2015-01-26 18:38 PST, Simon Fraser (smfr)
simon.fraser: review+
Eugene But
Comment 1 2015-01-07 14:01:29 PST
Created attachment 244196 [details] Crash Log
Eugene But
Comment 2 2015-01-07 16:06:02 PST
Radar ID: 19036018
Simon Fraser (smfr)
Comment 3 2015-01-26 18:36:34 PST
*** Bug 140915 has been marked as a duplicate of this bug. ***
Simon Fraser (smfr)
Comment 4 2015-01-26 18:38:31 PST
Simon Fraser (smfr)
Comment 5 2015-01-26 18:39:12 PST
Comment on attachment 245398 [details] Patch Sam said Yeah.
WebKit Commit Bot
Comment 6 2015-01-26 18:40:00 PST
Attachment 245398 [details] did not pass style-queue: ERROR: Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewEvaluateJavaScript.mm:45: Place brace on its own line for function definitions. [whitespace/braces] [4] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Simon Fraser (smfr)
Comment 7 2015-01-26 18:41:55 PST
Stuart Morgan
Comment 8 2015-01-27 06:50:40 PST
Thanks! Is there any reasonable way for us to work around this in versions of the OS that don't have the fix?
Simon Fraser (smfr)
Comment 9 2015-01-27 07:37:35 PST
Try calling -copy on the completion block that you send into -[WKWebView evaluateJavaScript:completionHandler:], and manage the lifetime of the resulting block yourself.
chenwenhong
Comment 10 2015-07-14 06:48:21 PDT
Hi,I fixed the WebKit's bug. The code below: - (void)evaluateJavaScript:(NSString *)javaScriptString completionHandler:(void (^)(id, NSError *))completionHandler { id strongSelf = self; [super evaluateJavaScript:javaScriptString completionHandler:^(id r, NSError *e) { [strongSelf title]; if (completionHandler) { completionHandler(r, e); } }]; }
Note You need to log in before you can comment on or make changes to this bug.