Memory leak when using WKScriptMessageHandler

前端 未结 4 968
别跟我提以往
别跟我提以往 2021-02-02 00:36

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

4条回答
  •  执笔经年
    2021-02-02 01:20

    You've got a retain cycle here. In your code, ViewController retains WKWebView, WKWebView retains WKWebViewConfiguration, WKWebViewConfiguration retains WKUserContentController and your WKUserContentController retains your ViewController. Just like in comment above, you have to remove scriptHandler by calling removeScriptMessageHandlerForName, before closing your view controller.

提交回复
热议问题