Skip to content

fix(ScreenContainer): defer detachment when all screens transiently inactive#1

Merged
steve228uk merged 2 commits intomainfrom
claude/fix-detach-animation-timing-KsQga
Apr 11, 2026
Merged

fix(ScreenContainer): defer detachment when all screens transiently inactive#1
steve228uk merged 2 commits intomainfrom
claude/fix-detach-animation-timing-KsQga

Conversation

@steve228uk
Copy link
Copy Markdown
Owner

When activityState is driven by an Animated.Value interpolation
(as react-navigation does for tab animations), each screen's state is
updated frame-by-frame and independently. During rapid tab switching
there is a brief window where ALL screens cross the inactive threshold
simultaneously: the leaving screen's animated value has already dropped
below 1.0 while the arriving screen's has not yet risen above 1.0.

Previously, the leaving screen was detached immediately upon reaching
activityState == 0, even if no other screen was active or
transitioning. This left the container with no visible screen for one
or more frames, producing a blank-screen flash — the bug reported in
react-navigation/react-navigation#12755.

The fix: only detach an in-tree inactive screen when at least one other
screen is still active or transitioning, guaranteeing something remains
visible until the arriving screen takes over. Screens that have been
removed from the React tree entirely (orphaned) are always detached
immediately since they can never become active again.

Applied to both iOS (RNSScreenContainer.mm) and Android
(ScreenContainer.kt) for consistency.

https://claude.ai/code/session_01HSsJnvYwm3gHfeH27CXRsW

claude added 2 commits April 11, 2026 08:53
…nactive

When `activityState` is driven by an `Animated.Value` interpolation
(as react-navigation does for tab animations), each screen's state is
updated frame-by-frame and independently. During rapid tab switching
there is a brief window where ALL screens cross the inactive threshold
simultaneously: the leaving screen's animated value has already dropped
below 1.0 while the arriving screen's has not yet risen above 1.0.

Previously, the leaving screen was detached immediately upon reaching
`activityState == 0`, even if no other screen was active or
transitioning. This left the container with no visible screen for one
or more frames, producing a blank-screen flash — the bug reported in
react-navigation/react-navigation#12755.

The fix: only detach an in-tree inactive screen when at least one other
screen is still active or transitioning, guaranteeing something remains
visible until the arriving screen takes over. Screens that have been
removed from the React tree entirely (orphaned) are always detached
immediately since they can never become active again.

Applied to both iOS (`RNSScreenContainer.mm`) and Android
(`ScreenContainer.kt`) for consistency.

https://claude.ai/code/session_01HSsJnvYwm3gHfeH27CXRsW
…, trim comments

Rename the guard variable to better reflect its intent (something must
remain visible before we detach), and shorten the explanatory comments
to drop the self-evident orphan-handling sentence.

https://claude.ai/code/session_01HSsJnvYwm3gHfeH27CXRsW
@steve228uk steve228uk merged commit 83cc9ac into main Apr 11, 2026
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