From 477697ad9e19a3e93435d6a5a0d8c5ec6659ffb1 Mon Sep 17 00:00:00 2001 From: dimitris Date: Wed, 20 May 2026 14:22:53 +0200 Subject: [PATCH 1/2] K9WebViewClient: log WebView main-frame load errors K9WebViewClient is the WebViewClient used to render email message bodies in the legacy message view. It currently overrides shouldOverrideUrlLoading and shouldInterceptRequest, but not onReceivedError. When the WebView fails to load the main frame, the failure is swallowed and the user is left with a blank message body. The error reason is not in the device log either, which makes triage difficult. Add the API 23+ onReceivedError override, scoped to request.isForMainFrame so that occasional sub-resource errors (broken inline images, blocked http content in https mails, etc.) do not flood the log. minSdk for the legacy module is 23, so the deprecated pre-M overload is intentionally not added. No behaviour change for successful loads; on failure, the error code, description, and failing URL are recorded via the legacy Log helper that is already used elsewhere in this file. --- .../src/main/java/com/fsck/k9/view/K9WebViewClient.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/legacy/ui/legacy/src/main/java/com/fsck/k9/view/K9WebViewClient.kt b/legacy/ui/legacy/src/main/java/com/fsck/k9/view/K9WebViewClient.kt index e2e102d851c..ac55b756f6f 100644 --- a/legacy/ui/legacy/src/main/java/com/fsck/k9/view/K9WebViewClient.kt +++ b/legacy/ui/legacy/src/main/java/com/fsck/k9/view/K9WebViewClient.kt @@ -6,6 +6,7 @@ import android.content.Intent import android.net.Uri import android.os.Build import android.provider.Browser +import android.webkit.WebResourceError import android.webkit.WebResourceRequest import android.webkit.WebResourceResponse import android.webkit.WebView @@ -120,6 +121,14 @@ class K9WebViewClient( onPageFinishedListener?.onPageFinished() } + @RequiresApi(Build.VERSION_CODES.M) + override fun onReceivedError(view: WebView, request: WebResourceRequest, error: WebResourceError) { + super.onReceivedError(view, request, error) + if (request.isForMainFrame) { + Log.d("Message WebView load error: %d %s for %s", error.errorCode, error.description, request.url) + } + } + companion object { private const val CID_SCHEME = "cid" private const val FILE_SCHEME = "file" From 5ad43d2942e93eb62ddc24c563eb0ac7aeea22f4 Mon Sep 17 00:00:00 2001 From: dimitris Date: Fri, 22 May 2026 16:33:02 +0200 Subject: [PATCH 2/2] Suppress detekt TooManyFunctions on K9WebViewClient --- .../ui/legacy/src/main/java/com/fsck/k9/view/K9WebViewClient.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/legacy/ui/legacy/src/main/java/com/fsck/k9/view/K9WebViewClient.kt b/legacy/ui/legacy/src/main/java/com/fsck/k9/view/K9WebViewClient.kt index ac55b756f6f..a8492676558 100644 --- a/legacy/ui/legacy/src/main/java/com/fsck/k9/view/K9WebViewClient.kt +++ b/legacy/ui/legacy/src/main/java/com/fsck/k9/view/K9WebViewClient.kt @@ -22,6 +22,7 @@ import net.thunderbird.core.logging.legacy.Log /** * [WebViewClient] that intercepts requests for `cid:` URIs to load the respective body part. */ +@Suppress("TooManyFunctions") class K9WebViewClient( private val clipboardManager: ClipboardManager, private val attachmentResolver: AttachmentResolver?,