Skip to content

NullPointerException: Attempt to invoke virtual method 'JavaTimerManager$IdleCallbackRunnable.cancel()' on a null object reference #44842

@gaearon

Description

@gaearon

Description

We got this in Sentry:

Attempt to invoke virtual method 'void com.facebook.react.modules.core.JavaTimerManager$IdleCallbackRunnable.cancel()' on a null object reference

The stack trace says it essentially happens here:

if (mCurrentIdleCallbackRunnable != null) {
mCurrentIdleCallbackRunnable.cancel();
}

The only way I can imagine it happening is due to concurrent access to mCurrentIdleCallbackRunnable. So I wonder if the fix is to capture mCurrentIdleCallbackRunnable locally before doing the null check? Or else add synchronized.

Steps to reproduce

Unknown. But! Look at the stack trace.

React Native Version

0.74.1

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: macOS 14.1
  CPU: (16) arm64 Apple M3 Max
  Memory: 71.08 GB / 128.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.13.1
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.21
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.5.2
    path: /usr/local/bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11330709
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.1
    wanted: 0.74.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

com.facebook.react.modules.core.JavaTimerManager$IdleFrameCallback in doFrame at line 103
com.facebook.react.modules.core.ReactChoreographer$1 in doFrame at line 89
android.view.Choreographer$CallbackRecord in run at line 1397
android.view.Choreographer$CallbackRecord in run at line 1408
android.view.Choreographer in doCallbacks at line 1008
android.view.Choreographer in doFrame at line 934
android.view.Choreographer$FrameDisplayEventReceiver in run at line 1382
android.os.Handler in handleCallback at line 959
android.os.Handler in dispatchMessage at line 100
android.os.Looper in loopOnce at line 232
android.os.Looper in loop at line 317
android.app.ActivityThread in main at line 8501
java.lang.reflect.Method in invoke
com.android.internal.os.RuntimeInit$MethodAndArgsCaller in run at line 552
com.android.internal.os.ZygoteInit in main at line 878

Reproducer

https://github.com/bluesky-social/social-app/

Screenshots and Videos

No response

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