Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK 52] Crash on Android when using presentation: 'formSheet' and switching apps #2627

Open
qretsar opened this issue Jan 16, 2025 · 3 comments
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided

Comments

@qretsar
Copy link

qretsar commented Jan 16, 2025

Description

I encountered an issue in Expo SDK 52 while using the presentation: 'formSheet' option in a stack screen. It works perfectly fine on both iOS and Android, except on Android when you:

Open the formSheet.
Switch to another app or access the task manager (e.g., swipe up to view all running apps) while the sheet is opened.
Return to the app.
The app crashes with the following error:

java.lang.IllegalStateException: Fragment already added: ScreenStackFragment{f1ecdea} (397f0ecd-ef24-42e1-8613-efd2d1e087c3 id=0xa)
androidx.fragment.app.FragmentStore.addFragment(FragmentStore.java:93)
androidx.fragment.app.FragmentManager.addFragment(FragmentManager.java:1503)
androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:387)
androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2009)
androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1895)
androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1845)
androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1782)
androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3042)
androidx.fragment.app.FragmentManager.dispatchStart(FragmentManager.java:2959)
androidx.fragment.app.Fragment.performStart(Fragment.java:3196)
androidx.fragment.app.FragmentStateManager.start(FragmentStateManager.java:628)
androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:290)
androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:114)
androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1455)
androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3034)
androidx.fragment.app.FragmentManager.dispatchStart(FragmentManager.java:2959)
androidx.fragment.app.FragmentController.dispatchStart(FragmentController.java:274)
androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:358)
androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:251)
android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1455)
android.app.Activity.performStart(Activity.java:8270)
android.app.ActivityThread.handleStartActivity(ActivityThread.java:3760)
android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:183)
android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:132)
android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2260)
android.os.Handler.dispatchMessage(Handler.java:106)
android.os.Looper.loopOnce(Looper.java:210)
android.os.Looper.loop(Looper.java:299)
android.app.ActivityThread.main(ActivityThread.java:8108)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045

This issue occurs in Expo Go, development builds, and release builds, meaning it's not just a development-related bug.

In Expo Go, the error message is not descriptive—making debugging difficult.

In a development or release build, the crash logs indicate:
java.lang.IllegalStateException: Fragment already added: ScreenStackFragment{f1ecdea}

Steps to reproduce

  1. Use a stack navigator in React Navigation.
  2. Add a screen with presentation: 'formSheet' as part of the stack.
  3. Open the screen on Android.
  4. Switch to another app using the task manager.
  5. Return to the app.

Snack or a link to a repository

https://github.com/qretsar/screens-reproduction

Screens version

4.4.0

React Native version

0.76.6

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

Xiaomi 12 (Android 12), Emulator, and others

Acknowledgements

Yes

@bhavyavishnani
Copy link

Did you found the solution?
same happening with me!!

@github-actions github-actions bot added Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided labels Jan 16, 2025
@kkafar
Copy link
Member

kkafar commented Jan 16, 2025

Thanks for the report. We'll look into this.

@christianbach
Copy link

We are also seeing this in our app. We reverted to only showing formSheet for iOS and a custom "bottom-sheet" for android. Seeing this in the emulator and real device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided
Projects
None yet
Development

No branches or pull requests

4 participants