Skip to content

Print WebView swallows main-frame load errors #364

@jim-daf

Description

@jim-daf

The hidden WebView built in MainActivity#printText (app/src/main/kotlin/org/fossify/notes/activities/MainActivity.kt around line 1279) drives the print flow by setting a WebViewClient that overrides shouldOverrideUrlLoading and onPageFinished. The onPageFinished callback is what actually starts the print job via createWebPrintJob.

The same WebViewClient does not override onReceivedError. So if loadData fails (for example on a very large note that exceeds WebView limits, or under a transient renderer process error) the result is:

  • onPageFinished never fires, so createWebPrintJob is never called and no print dialog appears.
  • onReceivedError is not handled either, so the user gets no toast, no log line, no error.

The user taps "Print", nothing happens, and there is no feedback at all.

Suggested fix: add onReceivedError(view, request, error) on the same anonymous WebViewClient, guard with request.isForMainFrame so any sub-resource failure does not trigger the error path twice, and surface the failure to the user. The codebase already has a translated R.string.unknown_error_occurred in org.fossify.commons, which is what printText already uses elsewhere in this activity via showErrorToast. PR for this at #365.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions