Bug 231659

Summary: removeAllScriptMessageHandlers causes retain where removeScriptMessageHandlerForName does not
Product: WebKit Reporter: Peter N Lewis <peter>
Component: WebKit APIAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: achristensen, ggaren, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 15   
Hardware: Mac (Intel)   
OS: macOS 11   

Description Peter N Lewis 2021-10-13 00:19:26 PDT
In my WKWebView controller, I use:

	[i_webView.configuration.userContentController addScriptMessageHandler:self name:@"KeyboardMaestro"];

This creates a reference to the controller (self). The controller will not be dealloc'ed when the window is closed.

If in the willClose method I do:

		[strongSelf1->i_webView.configuration.userContentController removeScriptMessageHandlerForName:@"KeyboardMaestro"];

The controller will dealloc normally.

However, if I instead fo:


		[strongSelf1->i_webView.configuration.userContentController removeAllScriptMessageHandlers];

The controller does not dealloc, so a reference is retained.

Since removeAllScriptMessageHandlers should cover the case of removeScriptMessageHandlerForName:@"KeyboardMaestro" and more, this seems to be a bug.
Comment 1 Radar WebKit Bug Importer 2021-10-20 00:20:18 PDT
<rdar://problem/84450759>
Comment 2 Alex Christensen 2021-10-20 08:06:08 PDT

*** This bug has been marked as a duplicate of bug 228271 ***