Bug 231659 - removeAllScriptMessageHandlers causes retain where removeScriptMessageHandlerForName does not
Summary: removeAllScriptMessageHandlers causes retain where removeScriptMessageHandler...
Status: RESOLVED DUPLICATE of bug 228271
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: Safari 15
Hardware: Mac (Intel) macOS 11
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-10-13 00:19 PDT by Peter N Lewis
Modified: 2021-10-20 08:06 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***