Skip to content

fix(Android, Stack v4): Fix crash when a Screen is reordered inside ScreenStack - #4492

Draft
t0maboro wants to merge 2 commits into
mainfrom
@t0maboro/fix-crash-on-screen-reordering-android
Draft

fix(Android, Stack v4): Fix crash when a Screen is reordered inside ScreenStack#4492
t0maboro wants to merge 2 commits into
mainfrom
@t0maboro/fix-crash-on-screen-reordering-android

Conversation

@t0maboro

@t0maboro t0maboro commented Aug 12, 2026

Copy link
Copy Markdown
Member

Description

Fabric treats a screen move as a pair of Remove and Insert mutations in a single transaction. Our removal-detection paths could not detect a move to another parent and starts removal transition unconditionally, marking the whole subtree of a screen that stays alive with startViewTransition. ViewGroup does not clear mParent for views in mTransitioningViews, so when the same commit also reorders children inside the moved screen, their Remove leaves mParent set and then Insert of the same view instance throws.

Proposing a simple mechanism for detecting when the Screen moves to another parent, and in that case, removing it immediately from the current parent.

Changes

  • detected Remove+Insert of the same tag is a move, which shouldn't notify the removal path

Before & after - visual documentation

Before After
Screen.Recording.2026-08-12.at.15.09.04.mov
Screen.Recording.2026-08-12.at.15.07.31.mov

Test plan

Added dedicated test

Checklist

  • Included code example that can be used to test this change.
  • For visual changes, included screenshots / GIFs / recordings documenting the change.
  • For API changes, updated relevant public types.
  • Ensured that CI passes

@t0maboro
t0maboro requested a balanced review from Copilot August 12, 2026 13:06
@t0maboro
t0maboro marked this pull request as draft August 12, 2026 13:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes an Android Stack v4 crash caused by Fabric screen reordering.

Changes:

  • Detects screen moves within mounting transactions.
  • Detaches moved screens without starting removal transitions.
  • Adds a manual regression reproducer.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
cpp/legacy/RNSScreenRemovalListener.cpp Distinguishes moves from removals.
android/.../ScreenStackViewManager.kt Immediately detaches moved screens.
apps/src/tests/issue-tests/TestXXXX.tsx Reproduces concurrent screen and child reordering.
apps/src/tests/issue-tests/index.ts Registers the reproducer.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

export { default as Test4357 } from './Test4357';
export { default as Test4361 } from './Test4361';
export { default as Test4423 } from './Test4423';
export { default as TestXXXX } from './TestXXXX';
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.

2 participants