From 96e483046c9128dbcaec21efb0f5d619c6b1185f Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Thu, 27 May 2021 16:43:46 +0200 Subject: [PATCH] fix(android): Reset bridge on onPageStarted only (#4634) --- .../main/java/com/getcapacitor/BridgeWebViewClient.java | 7 +++++++ .../src/main/java/com/getcapacitor/WebViewLocalServer.java | 3 --- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/android/capacitor/src/main/java/com/getcapacitor/BridgeWebViewClient.java b/android/capacitor/src/main/java/com/getcapacitor/BridgeWebViewClient.java index a2b81a85e8..9335185862 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/BridgeWebViewClient.java +++ b/android/capacitor/src/main/java/com/getcapacitor/BridgeWebViewClient.java @@ -1,5 +1,6 @@ package com.getcapacitor; +import android.graphics.Bitmap; import android.net.Uri; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; @@ -43,4 +44,10 @@ public void onPageFinished(WebView view, String url) { } } } + + @Override + public void onPageStarted(WebView view, String url, Bitmap favicon) { + super.onPageStarted(view, url, favicon); + bridge.reset(); + } } diff --git a/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java b/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java index b0da6c14ad..bf1491d01b 100755 --- a/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java +++ b/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java @@ -266,7 +266,6 @@ private WebResourceResponse handleLocalRequest(WebResourceRequest request, PathH responseStream = jsInjector.getInjectedStream(responseStream); - bridge.reset(); int statusCode = getStatusCode(responseStream, handler.getStatusCode()); return new WebResourceResponse( "text/html", @@ -295,7 +294,6 @@ private WebResourceResponse handleLocalRequest(WebResourceRequest request, PathH // TODO: Conjure up a bit more subtlety than this if (ext.equals(".html")) { responseStream = jsInjector.getInjectedStream(responseStream); - bridge.reset(); } String mimeType = getMimeType(path, responseStream); @@ -351,7 +349,6 @@ private WebResourceResponse handleProxyRequest(WebResourceRequest request, PathH } InputStream responseStream = conn.getInputStream(); responseStream = jsInjector.getInjectedStream(responseStream); - bridge.reset(); return new WebResourceResponse( "text/html", handler.getEncoding(),