Skip to content

[🐛] Attempt to invoke virtual method 'void com.google.firebase.perf.metrics.Trace.stop()' on a null object reference #8938

@retyui

Description

@retyui

Issue

🔥 I've got this issue 37k times in total in production, Android only. App is in background: true

// js part
const creatingTrace = perf.startTrace(eventName);
const result = await method(...args);
creatingTrace.then((trace) => trace.stop()); // <-- error here
return result;

Project Files

...

Javascript

package.json:

  "dependencies": {
    "react-native": "0.82.1",
    "@react-native-firebase/analytics": "^23.5.0",
    "@react-native-firebase/app": "^23.5.0",
    "@react-native-firebase/crashlytics": "^23.5.0",
    "@react-native-firebase/functions": "^23.5.0",
    "@react-native-firebase/messaging": "^23.5.0",
    "@react-native-firebase/perf": "^23.5.0",
    "@react-native-firebase/remote-config": "^23.5.0"
}

firebase.json for react-native-firebase v6:

{
  "react-native": {
    "google_analytics_adid_collection_enabled": false
  }
}

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
# N/A

AppDelegate.m:

// N/A


Android

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

 System:
  OS: macOS 15.7.3
  CPU: (11) arm64 Apple M3 Pro
  Memory: 2.46 GB / 36.00 GB
  Shell:
    version: 4.0.1
    path: /opt/homebrew/bin/fish
Binaries:
  Node:
    version: 24.13.1
    path: /usr/local/bin/node
  Yarn:
    version: 4.13.0
    path: /opt/homebrew/bin/yarn
  npm:
    version: 11.8.0
    path: /usr/local/bin/npm
  Watchman:
    version: 2025.09.01.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/xxx/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2025.3 AI-253.30387.90.2532.14935130
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.13
    path: /usr/bin/javac
  Ruby:
    version: 3.4.2
    path: /Users/xxx/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.2
    wanted: ^20.0.0
  react:
    installed: 19.1.1
    wanted: 19.1.1
  react-native:
    installed: 0.82.1
    wanted: 0.82.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • 23.5.0
  • Firebase module(s) you're using that has the issue:
    • Perf
  • Are you using TypeScript?
    • Y & 6.0


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions