|  | @@ -17,6 +17,7 @@ import android.os.Environment;
 | 
	
		
			
			| 17 | 17 |  import androidx.annotation.RequiresApi;
 | 
	
		
			
			| 18 | 18 |  import androidx.core.content.ContextCompat;
 | 
	
		
			
			| 19 | 19 |  import android.text.TextUtils;
 | 
	
		
			
			|  | 20 | +import android.util.Log;
 | 
	
		
			
			| 20 | 21 |  import android.view.Gravity;
 | 
	
		
			
			| 21 | 22 |  import android.view.View;
 | 
	
		
			
			| 22 | 23 |  import android.view.ViewGroup;
 | 
	
	
		
			
			|  | @@ -27,6 +28,7 @@ import android.webkit.CookieManager;
 | 
	
		
			
			| 27 | 28 |  import android.webkit.DownloadListener;
 | 
	
		
			
			| 28 | 29 |  import android.webkit.GeolocationPermissions;
 | 
	
		
			
			| 29 | 30 |  import android.webkit.JavascriptInterface;
 | 
	
		
			
			|  | 31 | +import android.webkit.RenderProcessGoneDetail;
 | 
	
		
			
			| 30 | 32 |  import android.webkit.SslErrorHandler;
 | 
	
		
			
			| 31 | 33 |  import android.webkit.PermissionRequest;
 | 
	
		
			
			| 32 | 34 |  import android.webkit.URLUtil;
 | 
	
	
		
			
			|  | @@ -69,6 +71,7 @@ import com.reactnativecommunity.webview.events.TopLoadingProgressEvent;
 | 
	
		
			
			| 69 | 71 |  import com.reactnativecommunity.webview.events.TopLoadingStartEvent;
 | 
	
		
			
			| 70 | 72 |  import com.reactnativecommunity.webview.events.TopMessageEvent;
 | 
	
		
			
			| 71 | 73 |  import com.reactnativecommunity.webview.events.TopShouldStartLoadWithRequestEvent;
 | 
	
		
			
			|  | 74 | +import com.reactnativecommunity.webview.events.TopRenderProcessGoneEvent;
 | 
	
		
			
			| 72 | 75 |  
 | 
	
		
			
			| 73 | 76 |  import org.json.JSONException;
 | 
	
		
			
			| 74 | 77 |  import org.json.JSONObject;
 | 
	
	
		
			
			|  | @@ -575,6 +578,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
 | 
	
		
			
			| 575 | 578 |      export.put(TopShouldStartLoadWithRequestEvent.EVENT_NAME, MapBuilder.of("registrationName", "onShouldStartLoadWithRequest"));
 | 
	
		
			
			| 576 | 579 |      export.put(ScrollEventType.getJSEventName(ScrollEventType.SCROLL), MapBuilder.of("registrationName", "onScroll"));
 | 
	
		
			
			| 577 | 580 |      export.put(TopHttpErrorEvent.EVENT_NAME, MapBuilder.of("registrationName", "onHttpError"));
 | 
	
		
			
			|  | 581 | +    export.put(TopRenderProcessGoneEvent.EVENT_NAME, MapBuilder.of("registrationName", "onRenderProcessGone"));
 | 
	
		
			
			| 578 | 582 |      return export;
 | 
	
		
			
			| 579 | 583 |    }
 | 
	
		
			
			| 580 | 584 |  
 | 
	
	
		
			
			|  | @@ -771,7 +775,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
 | 
	
		
			
			| 771 | 775 |        mLastLoadFailed = false;
 | 
	
		
			
			| 772 | 776 |  
 | 
	
		
			
			| 773 | 777 |        RNCWebView reactWebView = (RNCWebView) webView;
 | 
	
		
			
			| 774 |  | -      reactWebView.callInjectedJavaScriptBeforeContentLoaded();       
 | 
	
		
			
			|  | 778 | +      reactWebView.callInjectedJavaScriptBeforeContentLoaded();
 | 
	
		
			
			| 775 | 779 |  
 | 
	
		
			
			| 776 | 780 |        dispatchEvent(
 | 
	
		
			
			| 777 | 781 |          webView,
 | 
	
	
		
			
			|  | @@ -828,11 +832,11 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
 | 
	
		
			
			| 828 | 832 |            case SslError.SSL_UNTRUSTED:
 | 
	
		
			
			| 829 | 833 |              description = "The certificate authority is not trusted";
 | 
	
		
			
			| 830 | 834 |              break;
 | 
	
		
			
			| 831 |  | -          default: 
 | 
	
		
			
			|  | 835 | +          default:
 | 
	
		
			
			| 832 | 836 |              description = "Unknown SSL Error";
 | 
	
		
			
			| 833 | 837 |              break;
 | 
	
		
			
			| 834 | 838 |          }
 | 
	
		
			
			| 835 |  | -        
 | 
	
		
			
			|  | 839 | +
 | 
	
		
			
			| 836 | 840 |          description = descriptionPrefix + description;
 | 
	
		
			
			| 837 | 841 |  
 | 
	
		
			
			| 838 | 842 |          this.onReceivedError(
 | 
	
	
		
			
			|  | @@ -842,7 +846,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
 | 
	
		
			
			| 842 | 846 |            failingUrl
 | 
	
		
			
			| 843 | 847 |          );
 | 
	
		
			
			| 844 | 848 |      }
 | 
	
		
			
			| 845 |  | -    
 | 
	
		
			
			|  | 849 | +
 | 
	
		
			
			| 846 | 850 |      @Override
 | 
	
		
			
			| 847 | 851 |      public void onReceivedError(
 | 
	
		
			
			| 848 | 852 |        WebView webView,
 | 
	
	
		
			
			|  | @@ -899,6 +903,41 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
 | 
	
		
			
			| 899 | 903 |        }
 | 
	
		
			
			| 900 | 904 |      }
 | 
	
		
			
			| 901 | 905 |  
 | 
	
		
			
			|  | 906 | +    @TargetApi(Build.VERSION_CODES.O)
 | 
	
		
			
			|  | 907 | +    @Override
 | 
	
		
			
			|  | 908 | +    public boolean onRenderProcessGone(WebView webView, RenderProcessGoneDetail detail) {
 | 
	
		
			
			|  | 909 | +        // WebViewClient.onRenderProcessGone was added in O.
 | 
	
		
			
			|  | 910 | +        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
 | 
	
		
			
			|  | 911 | +            return false;
 | 
	
		
			
			|  | 912 | +        }
 | 
	
		
			
			|  | 913 | +        super.onRenderProcessGone(webView, detail);
 | 
	
		
			
			|  | 914 | +
 | 
	
		
			
			|  | 915 | +        if(detail.didCrash()){
 | 
	
		
			
			|  | 916 | +          Log.e("RNCWebViewManager", "The WebView rendering process crashed.");
 | 
	
		
			
			|  | 917 | +        }
 | 
	
		
			
			|  | 918 | +        else{
 | 
	
		
			
			|  | 919 | +          Log.w("RNCWebViewManager", "The WebView rendering process was killed by the system.");
 | 
	
		
			
			|  | 920 | +        }
 | 
	
		
			
			|  | 921 | +
 | 
	
		
			
			|  | 922 | +        // if webView is null, we cannot return any event
 | 
	
		
			
			|  | 923 | +        // since the view is already dead/disposed
 | 
	
		
			
			|  | 924 | +        // still prevent the app crash by returning true.
 | 
	
		
			
			|  | 925 | +        if(webView == null){
 | 
	
		
			
			|  | 926 | +          return true;
 | 
	
		
			
			|  | 927 | +        }
 | 
	
		
			
			|  | 928 | +
 | 
	
		
			
			|  | 929 | +        WritableMap event = createWebViewEvent(webView, webView.getUrl());
 | 
	
		
			
			|  | 930 | +        event.putBoolean("didCrash", detail.didCrash());
 | 
	
		
			
			|  | 931 | +
 | 
	
		
			
			|  | 932 | +        dispatchEvent(
 | 
	
		
			
			|  | 933 | +          webView,
 | 
	
		
			
			|  | 934 | +          new TopRenderProcessGoneEvent(webView.getId(), event)
 | 
	
		
			
			|  | 935 | +        );
 | 
	
		
			
			|  | 936 | +
 | 
	
		
			
			|  | 937 | +        // returning false would crash the app.
 | 
	
		
			
			|  | 938 | +        return true;
 | 
	
		
			
			|  | 939 | +    }
 | 
	
		
			
			|  | 940 | +
 | 
	
		
			
			| 902 | 941 |      protected void emitFinishEvent(WebView webView, String url) {
 | 
	
		
			
			| 903 | 942 |        dispatchEvent(
 | 
	
		
			
			| 904 | 943 |          webView,
 |