Skip to content

Dismiss the LogBox dialog when LogBoxModule is invalidated - #60514

Open
vanglian wants to merge 1 commit into
react:mainfrom
vanglian:fix-logbox-dialog-on-reload
Open

vanglian wants to merge 1 commit into
react:mainfrom
vanglian:fix-logbox-dialog-on-reload

Conversation

@vanglian

@vanglian vanglian commented Dec 3, 2026

Copy link
Copy Markdown

Summary:

On Android, reloading the app while the LogBox inspector is open leaves a blank (black or white) full-screen window over the reloaded app.

The inspector is a LogBoxDialog shown by LogBoxDialogSurfaceDelegate.
When the React instance is torn down for the reload, LogBoxModule.invalidate() calls only surfaceDelegate.destroyContentView().
That destroys the LogBox root view but never dismisses the dialog, so its window stays on screen with nothing in it.
The reloaded app renders normally underneath, but the user only sees the empty window until they press Back, which then also delivers a hardwareBackPress to the new instance.

invalidate() now calls surfaceDelegate.hide().
In LogBoxDialogSurfaceDelegate, that dismisses the dialog, detaches the root view and then calls destroyContentView(), so the cleanup invalidate() did before still happens.

Changelog:

[ANDROID] [FIXED] - Dismiss the LogBox dialog on reload so it no longer leaves a blank window over the app

Test Plan:

Reproduced on a physical Android device (Redmi K20 Pro, Android 11) with React Native 0.86.3 (bridgeless, new architecture) in an Expo SDK 57 dev client:

  1. Log a console.error so the LogBox notification appears, then tap it to open the inspector.
  2. Reload from the dev server (r in Metro).
  3. The screen stays black. dumpsys window windows lists two windows for the activity: the reloaded app's window, which has its ReactSurfaceView, and the leftover LogBox dialog window on top. Logcat shows stopSurface(surfaceId = 11) ... reactInstance is null. Dropping work. for the LogBox surface.
  4. Pressing Back dismisses the leftover dialog.

Not done: I did not build React Native from source to run the patched module on the device, because the app consumes the prebuilt react-android artifact.
The change relies on hide() being safe when no dialog is showing, which LogBoxDialogSurfaceDelegate.hide() already is (isShowing() guards the dismiss, and the remaining steps are null-safe).

🤖 Generated with Claude Code

@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Dec 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant