fix(android): reset readiness when the editor crashes - #640
Draft
dcalhoun wants to merge 1 commit into
Draft
Conversation
`isEditorLoaded` was set once and never cleared — not on an editor crash, and not even on WebView process termination, which iOS does handle. Every guard built on it therefore kept passing after the editor's `ErrorBoundary` unmounted the editor and deleted the `window.editor.*` bridge methods. Receive the `onEditorUnavailable` message the editor now emits, clear readiness, and expose an `EditorUnavailableListener` so hosts can disable the controls that depend on the editor while leaving saving and closing available. This is a second line of defense behind #639, which stops the one call site that turned a failed read into an empty title. Here the calls stop being made at all. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VuxMbKtUsaUF8nUVgKdxwK
dcalhoun
added this pull request to stack #641
September 9, 2026 16:24
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/640")Built from 383662b |
This was referenced Sep 9, 2026
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?
Android never cleared
isEditorLoaded, so every guard built on it kept passing after the editor crashed.Why?
isEditorLoadedis set once inonEditorLoadedand cleared nowhere — not on an editor crash, and not even on WebView process termination, which iOS does handle incontrollerWebContentProcessDidTerminate.So after the editor's
ErrorBoundaryunmounts the editor and deletes thewindow.editor.*methods, calls still reach a web view that can no longer answer them. This is the Android half of CMM-2008; #638 covers iOS and adds theonEditorUnavailablemessage this receives.It also unblocks the host:
GutenbergKitEditorFragment.editorReadyhas the same never-reset problem, and itsupdateFromEditorguard cannot start working until GutenbergKit tells it the editor is gone.How?
onEditorUnavailableover the existingeditorDelegateinterface and clearisEditorLoaded.EditorUnavailableListenerplussetEditorDidBecomeUnavailable, mirroring the existingEditorAvailableListenerpattern, and clear it alongside the other listeners on teardown.Relationship to #639
#639 fixes the consequence — one call site that turned a failed read into an empty title, which WordPress-Android persisted locally and then sent to the server. This PR fixes the cause, so the call is not made at all. They are independent and worth having both: #639 protects any host on today's release without a host change, this one stops the whole class.
Both touch
GutenbergView.ktbut in different regions, so they should rebase cleanly in either order.Not included
didFireEditorLoadedis deliberately untouched. It guards the available listener against firing twice, and changing it would alter reload behaviour that has no reload path yet.GutenbergKitEditorFragment.editorReadyand disabling the controls that no longer function — is a separate WordPress-Android change.Testing Instructions
Unit tests:
./android/gradlew -p ./android :Gutenberg:testDebugUnitTest --tests "org.wordpress.gutenberg.GutenbergViewTest"Two tests cover this. Note the second asserts that no JavaScript reaches the web view rather than asserting on the callback — Robolectric's shadow WebView never invokes the
ValueCallback, so a callback-based assertion passes with or without the fix. I verified the committed version fails when the reset is removed.Manually, in the demo app:
chrome://inspect:adb logcat | grep GutenbergViewshowsEditorUnavailable received in native code.Accessibility Testing Instructions
N/A — no UI changes.
Screenshots or screencast
N/A
🤖 Generated with Claude Code
https://claude.ai/code/session_01VuxMbKtUsaUF8nUVgKdxwK