From 6cadc0bc79c8a0e41d698b75779d312cbef61a7f Mon Sep 17 00:00:00 2001 From: dimitris Date: Wed, 20 May 2026 14:44:24 +0200 Subject: [PATCH] WebxdcStoreActivity: log main-frame WebView load errors The WebxdcStoreActivity loads a remote store URL via webView.loadUrl (Prefs.getWebxdcStoreUrl). The current WebViewClient overrides shouldOverrideUrlLoading and shouldInterceptRequest, but not onReceivedError, so a failure at the WebView/network layer (URL resolution, TLS handshake, premature reset) is silent: nothing in adb logcat and no signal in the activity itself. interceptRequest already catches RPC failures and synthesises a plain text "Could not load apps. Are you online?" response, which covers the common offline case. But it can only do so once shouldInterceptRequest is actually invoked, which is not guaranteed for every kind of load failure. The point of this change is to leave a trace in the log for those leftover cases. Add onReceivedError on the same anonymous WebViewClient (API 23+), guard with request.isForMainFrame() so transient sub-resource errors do not spam the log, and log the error code and description via the existing Log helper and TAG. --- .../securesms/WebxdcStoreActivity.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/org/thoughtcrime/securesms/WebxdcStoreActivity.java b/src/main/java/org/thoughtcrime/securesms/WebxdcStoreActivity.java index 6111aca3b..2481d4d0f 100644 --- a/src/main/java/org/thoughtcrime/securesms/WebxdcStoreActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/WebxdcStoreActivity.java @@ -6,13 +6,16 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.util.Log; import android.view.MenuItem; +import android.webkit.WebResourceError; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Toast; +import androidx.annotation.RequiresApi; import androidx.appcompat.app.ActionBar; import chat.delta.rpc.Rpc; import chat.delta.rpc.RpcException; @@ -102,6 +105,18 @@ public WebResourceResponse shouldInterceptRequest( WebView view, WebResourceRequest request) { return interceptRequest(request.getUrl().toString()); } + + @Override + @RequiresApi(Build.VERSION_CODES.M) + public void onReceivedError( + WebView view, WebResourceRequest request, WebResourceError error) { + super.onReceivedError(view, request, error); + if (request.isForMainFrame()) { + Log.w( + TAG, + "Store load failed: " + error.getErrorCode() + " " + error.getDescription()); + } + } }); WebSettings webSettings = webView.getSettings();