You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/11/01 15:39:00 UTC

[jira] [Commented] (CB-13382) Cordova iOS - Method to correctly destroy CDVViewControllers webView object

    [ https://issues.apache.org/jira/browse/CB-13382?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16234232#comment-16234232 ] 

ASF GitHub Bot commented on CB-13382:
-------------------------------------

jcesarmobile commented on a change in pull request #342: CB-13382: (ios) Added destroyWebView method for CDVViewController
URL: https://github.com/apache/cordova-ios/pull/342#discussion_r148295633
 
 

 ##########
 File path: CordovaLib/Classes/Public/CDVViewController.m
 ##########
 @@ -767,13 +767,23 @@ - (void)onAppDidEnterBackground:(NSNotification*)notification
 
 // ///////////////////////
 
+- (void)destroyWebView
+{
+    self.webViewEngine = nil;
 
 Review comment:
   I think this won't do anything if we don't call all what you put on the dealloc. If we are going to offer this new method, it should do everything what is on the dealloc and dealloc just call it. 
   
   Anyway, the main problem of CB-13382 is that dealloc is not doing the complete cleanup of the webview, with the new code it will do it, so we don't really need to offer this new method as dealloc will do the cleaning automatically.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


> Cordova iOS - Method to correctly destroy CDVViewControllers webView object
> ---------------------------------------------------------------------------
>
>                 Key: CB-13382
>                 URL: https://issues.apache.org/jira/browse/CB-13382
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: cordova-ios
>    Affects Versions: cordova-ios 4.5.0
>            Reporter: Nick Deakin
>            Assignee: Suraj Pindoria
>            Priority: Minor
>
> We have an app where we are using multi CDVViewController instances where a user can switch between hybrid apps within the native app.
> The issue that as been lingering for a couple of years is that even though a CDVViewController instance can be set to nil, the webview contained within still remains in memory. This can be observed when using the safari debugger.
> This is particularly troublesome when the webview is 'closed', then the content files in the webview are updated, and finally the webview is recreated, showing the old content. Performing a cmd-r in safari debugger refreshes the view and shows the updated content. 
> We can also do this a [UIWebView reload], but it is not possible if the app changes it's URL to a none physical path, e.g. file:///xxxxx/myApp/www/index.html becomes file:///xxxxx/myApp/www/home, then we get a page load error.
> I've been able to get the webview completely removed by doing the following:
> add the following method to CDVViewController:
> {code:java}
> -(void)destroyWebView {
>     self.webViewEngine = nil;
> }
> {code}
> then in my view controllers destroy method:
> {code:java}
>     [self.webViewEngine loadHTMLString:@"about:blank" baseURL:nil];
>     [self.pluginObjects removeAllObjects];
>     [self.webView removeFromSuperview];
>     [self destroyWebView];
> {code}
> Setting webViewEngine to nil is an unavoidable step to completely destroying the webview, but it is readonly. 
> Therefore, i would really appreciate this destroyWebView method, or a similar cleanup method being added.
> Android has a method to clean up which is CordovaWebViewImpl.handleDestroy().
> This destroys all the plugins, sets the URL to 'about:blank' and then executes engine.destroy()
> Many thanks!
> Nick



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

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