Not sure if I hit a bug in WebKit or I am doing something horribly wrong, but I can\'t figure out how to use WKScriptMessageHandler without causing wha
I've encountered same problem on iOS 9 SDK.
I noticed userContentController.addScriptMessageHandler(self, name: "handler") will keep the reference of the handler. To prevent leaks, simply remove the message handler when you no longer need it. e.g. when you dismiss the said controller, call a clean up method that will call removeScriptMessageHandlerForName().
You might consider move the addScriptMessageHandler() to viewWillAppear and add a corresponding removeScriptMessageHandlerForName() calls in viewWillDisappear.