You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2020/06/24 17:00:43 UTC

[GitHub] [cordova-ios] j-crosson opened a new issue #920: CDVViewController leaks CDVWebViewWeakScriptMessageHandler when destroyed

j-crosson opened a new issue #920:
URL: https://github.com/apache/cordova-ios/issues/920


   # Bug Report
   
   ## Problem
   
   ### What is expected to happen?
   
   No leak
   
   ### What does actually happen?
   
   leak
   
   ## Information
   I’m working on a plugin that uses a subclassed CDVViewController in a modal view.  Works fine except for leaking CDVWebViewWeakScriptMessageHandler every time the view goes away.  I was able to stop the leak with the following change to CDVViewController.m.         
   
   - (void)dealloc
   {
       .
       .
       .
   
     WKWebView* wkWebView = (WKWebView*)self.webViewEngine.engineWebView;
     [wkWebView.configuration.userContentController removeScriptMessageHandlerForName:(@"cordova")]; //CDV_BRIDGE_NAME 
   
     self.webViewEngine = nil;
   }
   
   Not that this is the final fix, but it does point out the issue.
   
   In my plugin subclass I use this:
   
       deinit {
           let wkWebView = webViewEngine.engineWebView as! WKWebView
           wkWebView.configuration.userContentController.removeScriptMessageHandler(forName: "cordova")
         }
   
   The ordering is a bit different, but it seems to work.
   
   This would also be an issue when embedding Cordova WebViews in a native app.
   
   A related issue stems from the integration of the SplashScreen plugin into CDVViewController.  I’m showing a non-startup view and don’t want to see a startup image (a Webview embedded in a native app would have the same issue)  In my subclassed ViewController “viewDidLoad”, I replace “launchView” with a UIVIew with a selectable background color.  No flashes or startup images show. Works fine. My issue is that I have to use techniques I’d rather not use to expose “private” class members
   
   
   
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   
   
   
   ### Environment, Platform, Device
   iOS 13.5.1
   
   
   
   ### Version information
   Cordova v9
   Cordova-ios 6.1.0
   Xcode 11.5
   macOS 10.15.5
   
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x ] I searched for existing GitHub issues
   - [x ] I updated all Cordova tooling to most recent version
   - [x ] I included all the necessary information above
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-ios] Durzan666 commented on issue #920: CDVViewController leaks CDVWebViewWeakScriptMessageHandler when destroyed

Posted by GitBox <gi...@apache.org>.
Durzan666 commented on issue #920:
URL: https://github.com/apache/cordova-ios/issues/920#issuecomment-705439749


   I use a subclass of CDVViewController with a NavigationController and observed that removing CDVViewController from NavigationController results in not calling dealloc because of strong references. I had to remove the strong references such as the MessageHandler in viewWillDisappear so dealloc got called.
   In short: I copied the whole code of dealloc to viewWillDisappear including the above fix. That fixed the leak of CDVViewController in my case.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-ios] Durzan666 commented on issue #920: CDVViewController leaks CDVWebViewWeakScriptMessageHandler when destroyed

Posted by GitBox <gi...@apache.org>.
Durzan666 commented on issue #920:
URL: https://github.com/apache/cordova-ios/issues/920#issuecomment-705439749


   I use a subclass of CDVViewController with a NavigationController and observed that removing CDVViewController from NavigationController results in not calling dealloc because of strong references. I had to remove the strong references such as the MessageHandler in viewWillDisappear so dealloc got called.
   In short: I copied the whole code of dealloc to viewWillDisappear including the above fix. That fixed the leak of CDVViewController in my case.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org