Skip to content

fix(android): soft exception when library try to access RCTDeviceEventEmitter before it is initialised#117

Merged
oblador merged 1 commit intooblador:masterfrom
war-in:fix-android-soft-exceptions-when-starting-the-app
Oct 23, 2025
Merged

fix(android): soft exception when library try to access RCTDeviceEventEmitter before it is initialised#117
oblador merged 1 commit intooblador:masterfrom
war-in:fix-android-soft-exceptions-when-starting-the-app

Conversation

@war-in
Copy link
Contributor

@war-in war-in commented Jul 16, 2025

This PR continues the improvement introduced here: #107

Currently, the app isn't crashing, but it's throwing soft exceptions when trying to emit events before RCTDeviceEventEmitter is initialised

Unhandled SoftException
com.facebook.react.bridge.ReactNoCrashSoftException: raiseSoftException(callWithExistingReactInstance(callFunctionOnModule("RCTDeviceEventEmitter", "emit"))): Execute: reactInstance is null. Dropping work.

To fix this, I wrapped the second emit with

if (getReactApplicationContext().hasActiveReactInstance()) {
    ...
}

and changed the previous hasActiveCatalystInstance() to hasActiveReactInstance() as it has been deprecated

Copy link
Owner

@oblador oblador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was deprecated in 0.65 so should be fine wrt bw compatibility! Thanks for the fix

@oblador oblador merged commit bc4c233 into oblador:master Oct 23, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants