-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Open
Labels
Description
Description
When an Android FragmentActivity hosts multiple ReactFragment instances and navigates between them, the React Native fragments lose their Activity reference (reactContext.currentActivity becomes null) after returning to the first fragment.
Bug symptoms:
- reactContext.currentActivity returns null after fragment navigation
- React Native bridge calls fail because Activity reference is lost
- UI interactions may become unresponsive
- Toast messages show "Activity: null (DETACHED - This is the bug!)"
Steps to reproduce
How to Reproduce the Activity Reference Loss
- Launch the app - Fragment A appears with instructions
- Click "Go to Fragment B" button
- Fragment B appears with purple header
- Press the Android Back button to return to Fragment A
- Watch the logcat output and toast messages
- Bug appears
⚠️ - Activity status shows "Activity: null (DETACHED - This is the bug!)"
What You'll See
The app automatically polls and displays the Activity state every 500ms:
- Before navigation: Toast and logs show Activity: MainActivity@ ✅
- After returning from Fragment B: Toast and logs show Activity: null (DETACHED) ❌
- Button may become unresponsive: The "Go to Fragment B" button won't work because the Activity reference is los
React Native Version
0.83.1
Affected Platforms
Runtime - Android
Output of npx @react-native-community/cli info
info Fetching system and libraries information...
System:
OS: macOS 15.7.3
CPU: (10) arm64 Apple M1 Max
Memory: 993.42 MB / 64.00 GB
Shell:
version: 3.2.57
path: /bin/bash
Binaries:
Node:
version: 22.19.0
path: /Users/eddie/.nvm/versions/node/v22.19.0/bin/node
Yarn:
version: 1.22.22
path: /opt/homebrew/bin/yarn
npm:
version: 10.9.3
path: /Users/eddie/.nvm/versions/node/v22.19.0/bin/npm
Watchman:
version: 2025.07.28.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 25.1
- iOS 26.1
- macOS 26.1
- tvOS 26.1
- visionOS 26.1
- watchOS 26.1
Android SDK:
API Levels:
- "30"
- "33"
- "34"
- "35"
- "36"
Build Tools:
- 28.0.3
- 29.0.2
- 30.0.2
- 30.0.3
- 32.0.0
- 32.1.0
- 33.0.1
- 34.0.0
- 35.0.0
- 36.0.0
System Images:
- android-28 | ARM 64 v8a
- android-28 | Google ARM64-V8a Play ARM 64 v8a
- android-29 | ARM 64 v8a
- android-29 | Google Play ARM 64 v8a
- android-30 | Google APIs ATD ARM 64 v8a
- android-32 | Google APIs ARM 64 v8a
- android-33 | Google APIs ARM 64 v8a
- android-34 | Google APIs ARM 64 v8a
- android-34 | Google Play ARM 64 v8a
- android-35 | ARM 64 v8a
- android-35 | Google Play ARM 64 v8a
- android-35 | Google Play Tablet ARM 64 v8a
- android-36 | Pre-Release 16 KB Page Size Google APIs ARM 64 v8a
- android-VanillaIceCream | Google APIs ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2025.2 AI-252.27397.103.2522.14617522
Xcode:
version: 26.1.1/17B100
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.14
path: /opt/homebrew/opt/openjdk@17/bin/javac
Ruby:
version: 3.4.5
path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 19.1.2
wanted: 19.1.2
react:
installed: 19.2.0
wanted: 19.2.0
react-native:
installed: 0.83.1
wanted: 0.83.1
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Stacktrace or Logs
2026-01-12 23:19:06.410 29719-29719 WindowOnBackDispatcher com.rnscreenscrashrepro W OnBackInvokedCallback is not enabled for the application.
Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
2026-01-12 23:19:06.444 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] onCreate - activity: com.rnscreenscrashrepro.MainActivity@950a235
2026-01-12 23:19:06.445 29719-29719 unknown:BridgelessReact com.rnscreenscrashrepro W ReactHost{0}.startSurface(surfaceId = 0): Schedule
2026-01-12 23:19:06.445 29719-29719 unknown:BridgelessReact com.rnscreenscrashrepro W ReactHost{0}.attachSurface(surfaceId = 0)
2026-01-12 23:19:06.445 29719-29752 unknown:BridgelessReact com.rnscreenscrashrepro W ReactHost{0}.getOrCreateReactInstanceTask()
2026-01-12 23:19:06.446 29719-29752 unknown:BridgelessReact com.rnscreenscrashrepro W ReactHost{0}.startSurface(surfaceId = 0): Execute
2026-01-12 23:19:06.447 29719-29763 ReactNativeJS com.rnscreenscrashrepro I Running "RNScreensCrashRepro" with {"rootTag":91,"initialProps":{"fragmentId":"A"},"fabric":true}
2026-01-12 23:19:06.447 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] onResume START - activity: com.rnscreenscrashrepro.MainActivity@950a235
2026-01-12 23:19:06.447 29719-29719 unknown:BridgelessReact com.rnscreenscrashrepro W ReactHost{0}.onHostResume(activity)
2026-01-12 23:19:06.450 29719-29719 unknown:BridgelessReact com.rnscreenscrashrepro W ReactContext.onHostResume()
2026-01-12 23:19:06.450 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] Starting periodic status check
2026-01-12 23:19:06.451 29719-29719 unknown:In...hMountItem com.rnscreenscrashrepro E Skipping batch of MountItems; was stopped [71].
2026-01-12 23:19:06.451 29719-29719 unknown:In...hMountItem com.rnscreenscrashrepro E Skipping batch of MountItems; was stopped [51].
2026-01-12 23:19:06.462 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] Periodic check - status: Activity: MainActivity@950a235
2026-01-12 23:19:06.466 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Activity state changed event:', 'Activity: MainActivity@950a235'
2026-01-12 23:19:06.468 29719-29719 [RNScreens] com.rnscreenscrashrepro W backTitleVisible prop is not available on Android
2026-01-12 23:19:06.468 29719-29719 [RNScreens] com.rnscreenscrashrepro W backTitleFontFamily prop is not available on Android
2026-01-12 23:19:06.468 29719-29719 [RNScreens] com.rnscreenscrashrepro W disableBackButtonMenu prop is not available on Android
2026-01-12 23:19:06.468 29719-29719 [RNScreens] com.rnscreenscrashrepro W largeTitleFontFamily prop is not available on Android
2026-01-12 23:19:06.468 29719-29719 [RNScreens] com.rnscreenscrashrepro W largeTitleFontWeight prop is not available on Android
2026-01-12 23:19:06.468 29719-29719 [RNScreens] com.rnscreenscrashrepro W largeTitleHideShadow prop is not available on Android
2026-01-12 23:19:06.478 29719-31256 unknown:Re...gWebSocket com.rnscreenscrashrepro W Couldn't connect to "ws://10.0.2.2:8081/message?device=sdk_gphone16k_arm64%20-%2016%20-%20API%2036&app=com.rnscreenscrashrepro&clientid=BridgelessDevSupportManager", will silently retry
2026-01-12 23:19:06.960 29719-29764 NavigationModule com.rnscreenscrashrepro D Activity status: Activity: MainActivity@950a235
2026-01-12 23:19:06.960 29719-29764 NavigationModule com.rnscreenscrashrepro D Has current activity: true
2026-01-12 23:19:06.961 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Auto-check - Activity status:', 'Activity: MainActivity@950a235'
2026-01-12 23:19:06.965 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] Periodic check - status: Activity: MainActivity@950a235
2026-01-12 23:19:06.967 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Activity state changed event:', 'Activity: MainActivity@950a235'
2026-01-12 23:19:07.467 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] Periodic check - status: Activity: MainActivity@950a235
2026-01-12 23:19:07.468 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Activity state changed event:', 'Activity: MainActivity@950a235'
2026-01-12 23:19:07.476 29719-29764 NavigationModule com.rnscreenscrashrepro D Activity status: Activity: MainActivity@950a235
2026-01-12 23:19:07.476 29719-29764 NavigationModule com.rnscreenscrashrepro D Has current activity: true
2026-01-12 23:19:07.478 29719-29763 ReactNativeJS com.rnscreenscrashrepro I [Fragment A] Navigating to Fragment B (Native Method)
2026-01-12 23:19:07.478 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Auto-check - Activity status:', 'Activity: MainActivity@950a235'
2026-01-12 23:19:07.499 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [B] onCreate - activity: com.rnscreenscrashrepro.MainActivity@950a235
2026-01-12 23:19:07.499 29719-29719 unknown:BridgelessReact com.rnscreenscrashrepro W ReactHost{0}.startSurface(surfaceId = 0): Schedule
2026-01-12 23:19:07.499 29719-29719 unknown:BridgelessReact com.rnscreenscrashrepro W ReactHost{0}.attachSurface(surfaceId = 0)
2026-01-12 23:19:07.500 29719-29752 unknown:BridgelessReact com.rnscreenscrashrepro W ReactHost{0}.getOrCreateReactInstanceTask()
2026-01-12 23:19:07.500 29719-29752 unknown:BridgelessReact com.rnscreenscrashrepro W ReactHost{0}.startSurface(surfaceId = 0): Execute
2026-01-12 23:19:07.501 29719-29763 ReactNativeJS com.rnscreenscrashrepro I Running "RNScreensCrashRepro" with {"rootTag":111,"initialProps":{"fragmentId":"B"},"fabric":true}
2026-01-12 23:19:07.501 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [B] onResume START - activity: com.rnscreenscrashrepro.MainActivity@950a235
2026-01-12 23:19:07.501 29719-29719 unknown:BridgelessReact com.rnscreenscrashrepro W ReactHost{0}.onHostResume(activity)
2026-01-12 23:19:07.501 29719-29719 unknown:ReactNative com.rnscreenscrashrepro W Packager connection already open, nooping.
2026-01-12 23:19:07.514 29719-29719 [RNScreens] com.rnscreenscrashrepro W backTitleVisible prop is not available on Android
2026-01-12 23:19:07.514 29719-29719 [RNScreens] com.rnscreenscrashrepro W backTitleFontFamily prop is not available on Android
2026-01-12 23:19:07.514 29719-29719 [RNScreens] com.rnscreenscrashrepro W disableBackButtonMenu prop is not available on Android
2026-01-12 23:19:07.514 29719-29719 [RNScreens] com.rnscreenscrashrepro W largeTitleFontFamily prop is not available on Android
2026-01-12 23:19:07.514 29719-29719 [RNScreens] com.rnscreenscrashrepro W largeTitleFontWeight prop is not available on Android
2026-01-12 23:19:07.514 29719-29719 [RNScreens] com.rnscreenscrashrepro W largeTitleHideShadow prop is not available on Android
2026-01-12 23:19:07.967 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] Periodic check - status: Activity: MainActivity@950a235
2026-01-12 23:19:07.968 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Activity state changed event:', 'Activity: MainActivity@950a235'
2026-01-12 23:19:07.993 29719-29764 NavigationModule com.rnscreenscrashrepro D Activity status: Activity: MainActivity@950a235
2026-01-12 23:19:07.993 29719-29764 NavigationModule com.rnscreenscrashrepro D Has current activity: true
2026-01-12 23:19:07.993 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Auto-check - Activity status:', 'Activity: MainActivity@950a235'
2026-01-12 23:19:08.468 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] Periodic check - status: Activity: MainActivity@950a235
2026-01-12 23:19:08.468 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Activity state changed event:', 'Activity: MainActivity@950a235'
2026-01-12 23:19:08.510 29719-29764 NavigationModule com.rnscreenscrashrepro D Activity status: Activity: MainActivity@950a235
2026-01-12 23:19:08.510 29719-29764 NavigationModule com.rnscreenscrashrepro D Has current activity: true
2026-01-12 23:19:08.510 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Auto-check - Activity status:', 'Activity: MainActivity@950a235'
2026-01-12 23:19:08.969 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] Periodic check - status: Activity: MainActivity@950a235
2026-01-12 23:19:08.969 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Activity state changed event:', 'Activity: MainActivity@950a235'
2026-01-12 23:19:09.027 29719-29764 NavigationModule com.rnscreenscrashrepro D Activity status: Activity: MainActivity@950a235
2026-01-12 23:19:09.027 29719-29764 NavigationModule com.rnscreenscrashrepro D Has current activity: true
2026-01-12 23:19:09.027 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Auto-check - Activity status:', 'Activity: MainActivity@950a235'
2026-01-12 23:19:09.470 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] Periodic check - status: Activity: MainActivity@950a235
2026-01-12 23:19:09.472 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Activity state changed event:', 'Activity: MainActivity@950a235'
2026-01-12 23:19:09.522 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [B] onPause - activity: com.rnscreenscrashrepro.MainActivity@950a235
2026-01-12 23:19:09.522 29719-29719 unknown:BridgelessReact com.rnscreenscrashrepro W ReactHost{0}.onHostPause(activity)
2026-01-12 23:19:09.524 29719-29719 unknown:BridgelessReact com.rnscreenscrashrepro W ReactContext.onHostPause()
2026-01-12 23:19:09.525 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [B] onStop - activity: com.rnscreenscrashrepro.MainActivity@950a235
2026-01-12 23:19:09.526 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [B] onDestroyView - activity: com.rnscreenscrashrepro.MainActivity@950a235
2026-01-12 23:19:09.527 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [B] onDestroy - activity: com.rnscreenscrashrepro.MainActivity@950a235
2026-01-12 23:19:09.527 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [B] isRemoving: true, isAdded: false
2026-01-12 23:19:09.527 29719-29719 unknown:BridgelessReact com.rnscreenscrashrepro W ReactHost{0}.stopSurface(surfaceId = 111): Schedule
2026-01-12 23:19:09.527 29719-29719 unknown:BridgelessReact com.rnscreenscrashrepro W ReactHost{0}.detachSurface(surfaceId = 111)
2026-01-12 23:19:09.527 29719-29719 unknown:BridgelessReact com.rnscreenscrashrepro W ReactHost{0}.onHostDestroy(activity)
2026-01-12 23:19:09.527 29719-29719 unknown:BridgelessReact com.rnscreenscrashrepro W ReactContext.onHostDestroy()
2026-01-12 23:19:09.527 29719-29719 unknown:ReactNative com.rnscreenscrashrepro E Tried to remove non-existent frame callback
2026-01-12 23:19:09.527 29719-29752 unknown:BridgelessReact com.rnscreenscrashrepro W ReactHost{0}.stopSurface(surfaceId = 111): Execute
2026-01-12 23:19:09.527 29719-29752 unknown:Su...ingManager com.rnscreenscrashrepro E Stopping surface [111]
2026-01-12 23:19:09.529 29719-29719 unknown:Su...ingManager com.rnscreenscrashrepro E Surface [111] was stopped on SurfaceMountingManager.
2026-01-12 23:19:09.537 29719-29764 unknown:ReactNative com.rnscreenscrashrepro W StatusBarModule: Ignored status bar change, current activity is null.
2026-01-12 23:19:09.537 29719-29764 unknown:ReactNative com.rnscreenscrashrepro W StatusBarModule: Ignored status bar change, current activity is null.
2026-01-12 23:19:09.972 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] Periodic check - status: Activity: null (DETACHED - This is the bug!)
2026-01-12 23:19:09.975 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Activity state changed event:', 'Activity: null (DETACHED - This is the bug!)'
2026-01-12 23:19:10.474 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] Periodic check - status: Activity: null (DETACHED - This is the bug!)
2026-01-12 23:19:10.476 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Activity state changed event:', 'Activity: null (DETACHED - This is the bug!)'
2026-01-12 23:19:10.976 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] Periodic check - status: Activity: null (DETACHED - This is the bug!)
2026-01-12 23:19:10.977 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Activity state changed event:', 'Activity: null (DETACHED - This is the bug!)'
2026-01-12 23:19:11.478 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] Periodic check - status: Activity: null (DETACHED - This is the bug!)
2026-01-12 23:19:11.478 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Activity state changed event:', 'Activity: null (DETACHED - This is the bug!)'
2026-01-12 23:19:11.979 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] Periodic check - status: Activity: null (DETACHED - This is the bug!)
2026-01-12 23:19:11.980 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Activity state changed event:', 'Activity: null (DETACHED - This is the bug!)'
2026-01-12 23:19:12.481 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] Periodic check - status: Activity: null (DETACHED - This is the bug!)
2026-01-12 23:19:12.482 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Activity state changed event:', 'Activity: null (DETACHED - This is the bug!)'
2026-01-12 23:19:12.982 29719-29719 CustomRNFragment com.rnscreenscrashrepro D [A] Periodic check - status: Activity: null (DETACHED - This is the bug!)
2026-01-12 23:19:12.983 29719-29763 ReactNativeJS com.rnscreenscrashrepro I '[Fragment A] Activity state changed event:', 'Activity: null (DETACHED - This is the bug!)'
MANDATORY Reproducer
https://github.com/chenxiangcxc/RNFragmentActivityRefDemo
Screenshots and Videos
First enter ReactNativeFragment A:

Navigate to ReactNativeFragment B:

Navigate back to ReactNativeFragment A (Lost activity reference!):
