feat(android): show why the editor document failed to load - #740
Merged
Merged
Conversation
A failed load left an endless spinner and an opaque logcat line. The error view now appears, and a dev server failure names the likely cause: the server not running, a missing cleartext entry, or an unreachable host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CSbnGRWvgz7WNn6cGFRKxs
XCFramework BuildThis PR's XCFramework is available for testing. Add the following to your .package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/740")Built from c2b7569 |
Timeouts, a disconnected device, and failed connections showed no hint, though they share the unreachable-host cause. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a physical device, localhost is the device itself, so a refused connection usually means the port isn't forwarded rather than the server being stopped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… HTTP error HTTP errors bypass onReceivedError, so a missing bundled index.html (a 404 from the asset loader) or a wrong dev server URL still left an endless spinner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a physical device, 10.0.2.2 times out rather than reaching the dev machine, and the generic reachability hint didn't name the cause. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dcalhoun
marked this pull request as ready for review
September 28, 2026 14:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Surface helpful information when the editor fails to load, rather than displaying an infinite loading indicator.
Why?
When developing locally, forgetting a configuration step led to cryptic error messages in LogCat or the Chrome inspector.
How?
Track the URL used for editor loading. When using the local development server, surface details of the error and actionable steps to resolve it.
Testing Instructions
GUTENBERG_EDITOR_URL=http://10.0.2.2:5173/and no dev server running, open a post in the demo app. The error view appears with the "Is the dev server running?" hint instead of a spinner.make serve-devand reopen the post. The editor loads.GUTENBERG_EDITOR_URLat the host's LAN IP without a matching entry innetwork_security_config.xml. The error view shows the cleartext hint.GUTENBERG_EDITOR_URL=http://10.0.2.2:5173/. After the connection times out, which can take a minute or two, the error view says10.0.2.2works only on the emulator and suggests the LAN IP address.GUTENBERG_EDITOR_URL=http://localhost:5173/withmake serve-devrunning and no port forwarding. The hint suggestsadb reverse tcp:5173 tcp:5173. Run it and reopen the post. The editor loads.GUTENBERG_EDITOR_URL, deleteandroid/Gutenberg/src/main/assets/index.html, and rebuild the demo app. Opening a post shows the localized error view instead of a spinner. Restore the file withmake copy-android-dist.GUTENBERG_EDITOR_URLunset and the bundle restored, open a post containing media. The editor loads as before.Accessibility Testing Instructions
N/A, no user-facing changes.
Screenshots or screencast
Screenshots
AI-generated details
Problem
When the editor document failed to load (e.g. the dev server wasn't running, or a physical device lacked a cleartext entry for the host's IP), the editor showed an endless spinner.
onReceivedErroronly logged the error object (Received web error: WV.cZ@6d44c24), and the globals injected into Chromium's error page raised a misleadinglocalStorageSecurityError.Mechanism
loadEditorrecords the URL it loads. When a main-frame request for that document fails, the existing error view replaces the spinner. This covers network failures (onReceivedError) and error statuses (onReceivedHttpError), including the asset loader's 404 for a missing bundledindex.html.ERR_CONNECTION_REFUSED: start the dev server withmake serve-dev. Forlocalhostor127.0.0.1, it also suggestsadb reverse tcp:<port> tcp:<port>.ERR_CLEARTEXT_NOT_PERMITTED: allow cleartext to the host in the network security config.10.0.2.2, it instead explains that the alias works only on the emulator and suggests the computer's LAN IP address.GUTENBERG_EDITOR_URLpoints at the dev server.Production path
GUTENBERG_EDITOR_URLis set, which comes only from the gitignoredlocal.properties. The bundled editor keeps the view's localized message, so no untranslated text reaches users.Testing
The Android library unit tests and
make lint-androidare green. On a device or emulator:GUTENBERG_EDITOR_URL=http://10.0.2.2:5173/and no dev server running, open a post in the demo app. The error view appears with the "Is the dev server running?" hint instead of a spinner.make serve-devand reopen the post. The editor loads.GUTENBERG_EDITOR_URLat the host's LAN IP without a matching entry innetwork_security_config.xml. The error view shows the cleartext hint.GUTENBERG_EDITOR_URL=http://10.0.2.2:5173/. After the connection times out, which can take a minute or two, the error view says10.0.2.2works only on the emulator and suggests the LAN IP address.GUTENBERG_EDITOR_URL=http://localhost:5173/withmake serve-devrunning and no port forwarding. The hint suggestsadb reverse tcp:5173 tcp:5173. Run it and reopen the post. The editor loads.GUTENBERG_EDITOR_URL, deleteandroid/Gutenberg/src/main/assets/index.html, and rebuild the demo app. Opening a post shows the localized error view instead of a spinner. Restore the file withmake copy-android-dist.GUTENBERG_EDITOR_URLunset and the bundle restored, open a post containing media. The editor loads as before.🤖 Generated with Claude Code
https://claude.ai/code/session_01CSbnGRWvgz7WNn6cGFRKxs