Skip to content

Take the server's error page back to the landing screen - #588

Merged
andiwand merged 2 commits into
mainfrom
server-error-page
Aug 14, 2026
Merged

Take the server's error page back to the landing screen#588
andiwand merged 2 commits into
mainfrom
server-error-page

Conversation

@andiwand

@andiwand andiwand commented Aug 14, 2026

Copy link
Copy Markdown
Member

A user sent a screenshot of the viewer showing nothing but Internal Server Error. That string is cpp-httplib's 500 page, shipped inside libodr_jni.so - the WebView was rendering the local server's error body as if it were the document.

Why nothing caught it

The core translates a page on the server thread, long after CoreLoader.render() reported success, so whatever it throws there only reaches the app as a status code. PageView overrode onReceivedError, which never fires for an HTTP status - the server did answer. So the failure was neither logged nor shown.

What this does

  • PageView overrides onReceivedHttpError too. Both it and onReceivedError take a main-frame failure through failPage(), which logs to CrashManager and calls the fragment back.
  • DocumentFragment.onPageFailed() unloads the document, drops back to the landing screen and raises the existing dialog_broken_file - the same "the file may be damaged, or something went wrong on our side" offer a file that will not open at all gets. Guarded so a second view, or a page failing on the way out, is a no-op, and deferred through replayOnStart while the activity is stopped.
  • Reports page_failed alongside the existing close_failed_document.

Routing onReceivedError the same way also covers a server that never bound: that comes back as ERR_CONNECTION_REFUSED and used to leave Chrome's error page on screen.

Verified

aPageTheServerCannotServeOffersContact opens test.odt, then points the page at a path the server has nothing under. On a Pixel 6 Pro emulator the path is exactly the one the bug takes:

E ODR : java.lang.RuntimeException: serving http://localhost:29665/file/odr/document.html.missing failed: 404 Not Found
I smn : page_failed content_type
I smn : close_failed_document

Full instrumented suite 68/68, plus spotlessCheck, testProDebugUnitTest, lintProDebug and assembleDebug.

🤖 Generated with Claude Code

The core translates a page on the server thread, long after CoreLoader
reported success, so a rendering failure only reaches the app as a status
code. onReceivedError never sees one - the server did answer - so nobody
detected it and the WebView rendered odrcore's "Internal Server Error"
page in place of the document.

PageView now overrides onReceivedHttpError as well, and both it and
onReceivedError take the main frame through failPage(). DocumentFragment
ends it where a document that would not open ends: back on the landing
screen with the contact dialog. This also covers a server that never
bound, which comes back as ERR_CONNECTION_REFUSED.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01EVNWZNEjtiodTCP8kvTfNP

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 32709b04f9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread app/src/main/java/app/opendocument/droid/ui/widget/PageView.kt
shouldOverrideUrlLoading returns false when it finds no app for a link,
which leaves the webview to try the navigation itself - and that failure
arrives as a main frame error too. failPage() now only gives up when the
url is our own content, so a dead hyperlink no longer presents the open
document as damaged.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01EVNWZNEjtiodTCP8kvTfNP
@andiwand
andiwand merged commit 344bedc into main Aug 14, 2026
7 checks passed
@andiwand
andiwand deleted the server-error-page branch August 14, 2026 18:33
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