Crash on Android: "Fragment already added" in ScreenStack.onUpdate with transparentModal after background/resume
@kkafar is already working on this.
Since Jun 23, 2026.
Assessment
This issue has not been assessed yet.
Description
Description
We get a steady stream of these crashes in production (~150 events / 135 users over the last 30 days, Android only):
java.lang.IllegalStateException: Fragment already added: ScreenStackFragment{62f0b31} (e990c58a-0b75-420f-9387-1d7d25cde9d6 id=0x831)
It always happens with a transparentModal screen on top of a native stack, typically right after the app was backgrounded and resumed (crash telemetry shows onStop → onSaveInstanceState → trim memory → onResume, then a navigation to the transparent screen a few seconds later). We have enableFreeze(true) set.
The crash comes from the re-attach branch in ScreenStack.onUpdate. When the top screen is translucent and visibleBottom's fragment is not added, every wrapper from visibleBottom upward gets re-added without checking isAdded:
if (visibleBottom != null && !visibleBottom.fragment.isAdded) {
val top = newTop
screenWrappers
.asSequence()
.dropWhile { it !== visibleBottom }
.forEach { wrapper ->
transaction.add(id, wrapper.fragment).runOnCommit { ... }
}
}
So if the screen under the transparent modal got detached while the modal's own fragment stayed attached, the loop re-adds the still-attached fragment and FragmentStore.addFragment throws. The sibling newTop branch right below does guard with !newTop.fragment.isAdded.
Looks closely related to #2627 (same exception with formSheet, fixed in 4.7.0) — a commenter there reported the transparent-modal flavor still crashing afterwards, which matches what we see.
Full stack trace
java.lang.IllegalStateException: Fragment already added: ScreenStackFragment{62f0b31} (e990c58a-0b75-420f-9387-1d7d25cde9d6 id=0x831)
androidx.fragment.app.FragmentStore.addFragment(FragmentStore.java:93)
androidx.fragment.app.FragmentManager.addFragment(FragmentManager.java:1733)
androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:389)
androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2280)
androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2165)
androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2115)
androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:2002)
androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:323)
com.swmansion.rnscreens.ScreenStack.onUpdate(ScreenStack.kt:298)
com.swmansion.rnscreens.ScreenContainer.performUpdates(ScreenContainer.kt:376)
com.swmansion.rnscreens.ScreensShadowNode.onBeforeLayout$lambda$0(ScreensShadowNode.kt:20)
com.facebook.react.uimanager.UIViewOperationQueue$UIBlockOperation.execute(UIViewOperationQueue.java:538)
com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:889)
com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:999)
com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1056)
com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.kt:25)
com.facebook.react.modules.core.ReactChoreographer.frameCallback$lambda$1(ReactChoreographer.kt:59)
android.view.Choreographer$CallbackRecord.run(Choreographer.java:1645)
android.view.Choreographer.doCallbacks(Choreographer.java:1252)
android.view.Choreographer.doFrame(Choreographer.java:1177)
android.os.Handler.dispatchMessage(Handler.java:125)
android.os.Looper.loop(Looper.java:367)
android.app.ActivityThread.main(ActivityThread.java:9333)
Steps to reproduce
We haven't found a deterministic repro — it's a race around fragment attachment state. The shape from telemetry is consistently:
- Native stack with opaque screens, push a screen with
presentation: 'transparentModal' - Background the app (recent apps), wait long enough for
onSaveInstanceState, resume - Trigger navigation / state changes that re-run
onUpdateshortly after resume
PR with a guard for the add loop incoming — happy to validate patches against our production app, since we can observe the crash rate there.
Snack or a link to a repository
No reliable minimal repro (race condition, see above)
Screens version
4.22.0 (the add loop is unchanged on current main)
React Native version
0.81.5
Platforms
Android
JavaScript runtime
Hermes
Workflow
React Native (without Expo)
Architecture
Paper (Old Architecture)
Build type
Release mode
Device
Real device
Device model
Various; e.g. Pixel 9 Pro (Android 16)
Acknowledgements
Yes
- Dominant language
- TypeScript
- Stars
- 3.7k
- Forks
- 714
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 71
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from software-mansion/react-native-screens
-
missing-repro platform:ios
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
software-mansion/react-native-screens#4168 · 10 comments · 2 reactions ·
-
area:stack-v4 platform:android
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
software-mansion/react-native-screens#3784 · 5 comments ·
-
cr:missing-info cr:missing-repro cr:platform:android missing-info missing-repro platform:android
Difficulty 4/5 3-5 days Newbie friendliness 42/100
software-mansion/react-native-screens#4677 · 4 comments ·
-
cr:missing-repro cr:platform:ios missing-repro platform:ios
software-mansion/react-native-screens#4671 · 3 comments · 1 assignee ·
-
cr:missing-info cr:missing-repro cr:platform:android missing-info missing-repro platform:android
software-mansion/react-native-screens#4664 · 3 comments · 1 assignee ·
All issues in software-mansion/react-native-screens
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
vercel/react-tweet#225 ·