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

Crash in completeHandler When @react-native-firebase/perf Is Installed (Any Version) #44

Open
nguptaesaral opened this issue Feb 28, 2025 · 1 comment

Comments

@nguptaesaral
Copy link

Is this a bug report, a feature request, or a question?

a bug report

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

on IOS

Environment

Environment
OS: macOS 15.3.1 (Apple M4, ARM64)
React Native: 0.73.9
Xcode: 16.2 (iOS SDK 18.2)
Node: 18.20.7
CocoaPods: 1.16.2

Dependencies:
"@kesha-antonov/react-native-background-downloader": "^3.2.1"
"@react-native-firebase/app": "^21.11.0"
"@react-native-firebase/perf": "^21.11.0"

Description

The app crashes with an exception in -[RNBackgroundDownloader completeHandler:resolver:rejecter:] whenever @react-native-firebase/perf is installed, regardless of the version (tested with 20.3.0, 20.4.0, 21.11.0). The crash does not occur when RNBackgroundDownloader is used alone or with @react-native-firebase/app (without perf). This suggests a compatibility issue between RNBackgroundDownloader and the Firebase Performance Monitoring SDK introduced by perf.

Steps to Reproduce

  1. Create a fresh React Native 0.73.9 project:
    npx @react-native-community/cli@latest init eSaral --version 0.73.9

2.Install @kesha-antonov/react-native-background-downloader:
npm install @kesha-antonov/react-native-background-downloader@^3.2.1
cd ios && pod install

3.Verify it works standalone:
Add this code in App.js:
const jobId = 'file123'

let task = download({
id: jobId,
url: 'https://thetestdata.com/assets/video/mp4/highquality/5k_Thetestdata.mp4',
destination: ${directories.documents}/file.zip,
metadata: {}
}).begin(({ expectedBytes, headers }) => {
console.log(Going to download ${expectedBytes} bytes!)
}).progress(({ bytesDownloaded, bytesTotal }) => {
console.log(Downloaded: ${bytesDownloaded / bytesTotal * 100}%)
}).done(({ bytesDownloaded, bytesTotal }) => {
console.log('Download is done!', { bytesDownloaded, bytesTotal })

// PROCESS YOUR STUFF

// FINISH DOWNLOAD JOB
completeHandler(jobId)

}).error(({ error, errorCode }) => {
console.log('Download canceled due to error: ', { error, errorCode });
})

  1. Run: npx react-native run-ios. No crash occurs.
  2. Install @react-native-firebase/app and @react-native-firebase/perf:
    npm install @react-native-firebase/[email protected] @react-native-firebase/[email protected]
    cd ios && pod install
  3. Run the app again: npx react-native run-ios.
  4. Trigger the download. The app crashes with the stack trace below.

Expected Behavior
The download should complete successfully without crashing, even with @react-native-firebase/perf installed, as long as perf APIs are not actively conflicting with RNBackgroundDownloader.

Actual Behavior
The app crashes when completeHandler is invoked, but only if @react-native-firebase/perf is present in the project. The crash does not occur without perf, even with @react-native-firebase/app installed.

Additional Notes
The crash persists across multiple perf versions (20.3.0, 20.4.0, 21.11.0), but not with @react-native-firebase/app alone (tested with 21.11.0).
Suspected cause: Firebase Performance Monitoring SDK (pulled in by perf) may interfere with RNBackgroundDownloader’s native bridge or threading.
No direct calls to perf APIs are needed—just its presence in the project triggers the issue.

Stack Trace:
Exception 'Attempted to invoke method -[RNBackgroundDownloader completeHandler:resolver:rejecter:] on a module of class fir_766D5815-3B21-427F-9D62-E898D66AD5C1_RNBackgroundDownloader' was thrown while invoking completeHandler on target RNBackgroundDownloader with params (
file123,
448,
449
)
callstack: (
0 CoreFoundation 0x00000001804b910c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x0000000180092da8 objc_exception_throw + 72
2 Foundation 0x0000000180e67e08 -[NSMutableDictionary(NSMutableDictionary) classForCoder] + 0
3 eSaral.debug.dylib 0x00000001037e7ec4 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 576
4 eSaral.debug.dylib 0x0000000103849d48 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicEiN12_GLOBAL__N_117SchedulingContextE + 1848
5 eSaral.debug.dylib 0x000000010384941c _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 136
6 eSaral.debug.dylib 0x0000000103849388 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28
7 libdispatch.dylib 0x0000000100514cd8 _dispatch_call_block_and_release + 24
8 libdispatch.dylib 0x00000001005165d0 _dispatch_client_callout + 16
9 libdispatch.dylib 0x000000010051e8b8 _dispatch_lane_serial_drain + 896
10 libdispatch.dylib 0x000000010051f628 _dispatch_lane_invoke + 420
11 libdispatch.dylib 0x000000010052c2cc _dispatch_root_queue_drain_deferred_wlh + 324
12 libdispatch.dylib 0x000000010052b838 _dispatch_workloop_worker_thread + 732
13 libsystem_pthread.dylib 0x000000010067bb74 _pthread_wqthread + 284
14 libsystem_pthread.dylib 0x000000010067a934 start_wqthread + 8
)
Type: Error | Timestamp: 2025-02-28 16:14:34.447896+05:30 | Process: eSaral | Library: eSaral.debug.dylib | Subsystem: com.facebook.react.log | Category: native | TID: 0x7abe2

@kesha-antonov
Copy link
Owner

Hi

I have same issue with other methods
Interesting why it's happening

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

No branches or pull requests

2 participants