Skip to content

react-native-performance - fix soft crash patch #66231

@war-in

Description

@war-in

If you haven't already, check out our contributing guidelines and patch guidelines for information on how to manage patches.


Patch Information

Library Name: ract-native-performance
Library Version: 5.1.4
Patch Number: 001
Patch Description: fix-soft-crash-by-checking-for-active-react-instance
Full Patch Filename: react-native-performance+5.1.4+001+fix-soft-crash-by-checking-for-active-react-instance.patch

Patch Details

Reason for Patch

react-native-performance emits some events using RCTDeviceEventEmitter on Android. Emitter should be used only after react instance has been created.
Otherwise, soft exception is thrown:

```
raiseSoftException(callWithExistingReactInstance(callFunctionOnModule("RCTDeviceEventEmitter", "emit"))): Execute: reactInstance is null. Dropping work.
```

Changes Made

I wrapped code emitting events ⬇️

getReactApplicationContext()
    .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
    .emit("mark", params);

with a check for react instance

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

Upstream Status

Upstream PR/Issue: oblador/react-native-performance#117

Related Information

PR Introducing Patch: #66230

Additional Notes

Checklist

  • Patch file is correctly named and placed in the appropriate directory
  • Patch is documented in the corresponding details.md file
  • This issue is linked in the details.md file
  • Upstream PR/issue has been created (if applicable)

Metadata

Metadata

Assignees

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