Skip to content

Android Old Arch Native Event Emitter - RN no longer receiving events while not current activity #51109

@henrygrant

Description

@henrygrant

Description

My application is a brownfield app that React Native was added to a couple of years ago. We have a couple of screens we have not rewritten yet. For example, our "change address" screen is still native, but many React Native based screens switch to the "change address" activity to enable our users to take that action.

Since we started our RN integration, we have emitted an event from the native screen that RN would "catch" and key off of as an indicator that we need to reload the customer data. When we updated to RN77, the RN instance stopped receiving events. In my project's code, I nullcheck reactContext and check the context's hasActiveReactInstance() (which replaced hasActiveCatalystInstance()). If any of those are false, I add the events to a queue that will be processed when the ReactInstance comes back. This doesn't function however, because hasActiveReactInstance() comes back as true even when I'm on a native activity.

This only occurs when a native activity is sending the event. If I fire an event from calling a bridge function, RN will receive the event. This isn't so useful though, as we rely on firing events from native screens that aren't aware of RN and pick them up on the RN side.

I haven't been able to find anything in the 77 changelog that changed this, but anecdotally it seems like the app no longer is executing javascript while a native activity is running. This wouldn't be a problem if I had something I could go off of to know when or when not to queue events, but it doesn't seem like hasActiveReactInstance() is my answer.

I'll also mention that I saw this issue on New Architecture, but switched back to Old Architecture expecting that to resolve the issue.

Steps to reproduce

npm i
npm run android
npm start, open debugger

In the reproduction in the description, you will land on a RN-based screen that has a button to go to a native activity. Tapping that will land you on a native screen with a button that will emit an event to RN. RN will never catch this event, as when you get back to the RN screen there is no evidence the event was ever fired. This was not the case in 76 (or 68-77), that event was processed even though a ReactActivity wasn't the current activity.

React Native Version

0.77.1

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info

System:
  OS: macOS 15.4.1
  CPU: (8) arm64 Apple M1
  Memory: 102.36 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.18.1
    path: ~/.nvm/versions/node/v20.18.1/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.8.2
    path: ~/.nvm/versions/node/v20.18.1/bin/npm
  Watchman:
    version: 2025.03.10.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.4
      - iOS 18.4
      - macOS 15.4
      - tvOS 18.4
      - visionOS 2.4
      - watchOS 11.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.3 AI-243.24978.46.2431.13208083
  Xcode:
    version: 16.3/16E140
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.15
    path: /usr/bin/javac
  Ruby:
    version: 3.4.2
    path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.77.1
    wanted: 0.77.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

no stacktrace

MANDATORY Reproducer

https://github.com/henrygrant/reproducer-react-native-event-debug/tree/77-events

Screenshots and Videos

Image Image Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions