We have an Android application which implements an embedded WebView "container" in which it executes customer Cordova apps.
Under certain conditions our container needs to terminate the customer app, and during this termination it attempts to do some resource cleanup. For example, to cleanup any possible lurking InAppBrowser resources it does (equivalent of a IAB.close) the following:
Unfortunately, we don't really know if user app was actually using InAppBrowser or not.
- If it was using IAB, then the above exec works.
- If it wasn’t using IAB, the above exec results in NPE (inAppWebView is null) since current InAppBrowser.java code assumes "close" won't be called without matching "open".
Proposed improvement below is to make the InAppBrowser’s "close" more robust, so if it gets called in an unusual scenario (e.g. without a prior "open") then it is just a harmless NOP.