Skip to content

Log WebView load errors during PDF export#170

Open
jim-daf wants to merge 1 commit into
OmGodse:masterfrom
jim-daf:pdf-webview-error-logging
Open

Log WebView load errors during PDF export#170
jim-daf wants to merge 1 commit into
OmGodse:masterfrom
jim-daf:pdf-webview-error-logging

Conversation

@jim-daf

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

Copy link
Copy Markdown

What this does

Adds a single onReceivedError(view, errorCode, description, failingUrl) override to the WebViewClient used by PostPDFGenerator.create(...) in app/src/main/java/android/print/PostPDFGenerator.kt. It logs the error code, description and failing URL with Log.w. Adds a small file-level private const val TAG = "PostPDFGenerator".

No behaviour change in the happy path. No new dependencies.

Why

onPageFinished currently fires regardless of whether the load succeeded, so a print that ended up with missing assets ships through createPrintDocumentAdapter(...) and produces a half-rendered PDF with no logcat trace. This override makes the failure visible so future "exported PDF is missing parts" reports have something concrete to look at.

Note on the signature

I used the deprecated 4-arg form rather than the API 23+ (WebView, WebResourceRequest, WebResourceError) overload on purpose. The app's minSdk is 21 and the framework dispatches the deprecated form on every API level when nothing else is overridden, so this single override actually fires for every user. Happy to switch to the new signature gated on Build.VERSION.SDK_INT >= M if you would prefer that style.

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.

1 participant