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.
<rdar://problem/84450759>
*** This bug has been marked as a duplicate of bug 228271 ***