Skip to content

WebxdcStoreActivity: log main-frame WebView load errors#154

Open
jim-daf wants to merge 1 commit into
ArcaneChat:mainfrom
jim-daf:webxdc-store-main-frame-errors
Open

WebxdcStoreActivity: log main-frame WebView load errors#154
jim-daf wants to merge 1 commit into
ArcaneChat:mainfrom
jim-daf:webxdc-store-main-frame-errors

Conversation

@jim-daf
Copy link
Copy Markdown

@jim-daf jim-daf commented May 20, 2026

Closes #153.

WebxdcStoreActivity loads a remote store URL with webView.loadUrl(Prefs.getWebxdcStoreUrl(this)). The existing WebViewClient overrides shouldOverrideUrlLoading and shouldInterceptRequest, but not onReceivedError, so WebView-layer load failures end up silent in adb logcat.

interceptRequest already catches RpcException and friends and synthesises a "Could not load apps. Are you online?" plain-text body, which is good UX for the offline case. The change here is strictly additive: a Log.w line that fires for request.isForMainFrame() errors only, so the next time someone reports "the store screen is blank" there is something in the log to go on.

@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());
    }
}

Notes:

  • API 23+ overload only. isForMainFrame() and WebResourceError are both API 23, and the project already uses @RequiresApi(21) on sibling overrides in the same class.
  • Sub-resource errors are filtered out by the isForMainFrame() guard so the log stays useful.
  • Uses the Log import that is already present in this file, and the TAG constant that is already defined on the class. No new permission, no new dependency, no behaviour change for successful loads.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebxdcStoreActivity does not log WebView main-frame load failures

1 participant