fix(ScreenContainer): defer detachment when all screens transiently inactive#1
Merged
steve228uk merged 2 commits intomainfrom Apr 11, 2026
Merged
Conversation
…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
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.
When
activityStateis driven by anAnimated.Valueinterpolation(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 ortransitioning. 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