breautek commented on code in PR #1574:
URL: https://github.com/apache/cordova-android/pull/1574#discussion_r1161134604


##########
framework/src/org/apache/cordova/PluginManager.java:
##########
@@ -617,4 +618,29 @@ public ArrayList<CordovaPluginPathHandler> 
getPluginPathHandlers() {
         }
         return handlers;
     }
+
+    /**
+     * Called when the WebView's render process has exited.
+     *
+     * See 
https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail)
+     *
+     * @return  true if the host application handled the situation that 
process has exited,
+     *          otherwise, application will crash if render process crashed, 
or be killed 
+     *          if render process was killed by the system.
+     */
+    public boolean onRenderProcessGone(RenderProcessGoneDetail detail) {
+        boolean result = false;
+        synchronized (this.entryMap) {
+            for (PluginEntry entry : this.entryMap.values()) {
+                CordovaPlugin plugin = pluginMap.get(entry.service);
+                if (plugin != null) {
+                    if (plugin.onRenderProcessGone(app, detail)) {

Review Comment:
   Here we are assuming the affected webview is indeed the cordova webview.
   
   > Multiple WebView instances may be associated with a single render process; 
onRenderProcessGone will be called for each WebView that was affected. The 
application's implementation of this callback should only attempt to clean up 
the specific WebView given as a parameter, and should not assume that other 
WebView instances are affected.
   
   I don't believe this is a safe assumption. While as far as Cordova is 
concerned, there is only 1 webview instance, however plugins may add additional 
instances (e.g. the in app browser plugin). Therefore I believe it is possible 
for a webview to crash in which is not the main cordova webview, but will still 
go through this hook.
   
   Therefore, I think a better approach here is to pass down the `WebView` 
instance down and let plugins decide if it's the webview it cares about.
   
   The `CordovaAndroid` plugin (the android core) may use this to check if the 
crashed webview is indeed the main webview, while the InAppBrowser plugin may 
use this reference to determine if it's one of the webviews it has created.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to