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

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

Closed
gaearon opened this issue Jun 8, 2024 · 4 comments
Labels
Newer Patch Available Resolution: PR Submitted A pull request with a fix has been provided.

Comments

@gaearon
Copy link
Collaborator

gaearon commented Jun 8, 2024

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

Copy link

github-actions bot commented Jun 8, 2024

⚠️ Newer Version of React Native is Available!
ℹ️ You are on a supported minor version, but it looks like there's a newer patch available - 0.74.2. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@github-actions github-actions bot added Newer Patch Available Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Jun 8, 2024
Copy link

github-actions bot commented Jun 8, 2024

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

@gaearon
Copy link
Collaborator Author

gaearon commented Jun 8, 2024

@javache thought maybe you could have a look at this! thanks :)

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Jun 8, 2024
@gaearon
Copy link
Collaborator Author

gaearon commented Jun 8, 2024

This seems like the same issue as #38832. It was closed by @cortinico for lack of symbolicated traces but I'm not sure I understand why (it does have a full stacktrace which does show the exact line that's throwing — because another variable can set that variable to null). Are more details needed at this point?

gaearon added a commit to bluesky-social/social-app that referenced this issue Jun 8, 2024
@cortinico cortinico added Resolution: PR Submitted A pull request with a fix has been provided. and removed Needs: Triage 🔍 Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Attention Issues where the author has responded to feedback. labels Jun 10, 2024
cortinico added a commit to cortinico/react-native that referenced this issue Jun 10, 2024
Summary:
This attempts to fix facebook#44842 by capturing the accessed field in a new variable.
We don't have a way to reproduce this & this is a best guess fix.

Changelog:
[Android] [Fixed] - Tentative fix for NPE `JavaTimerManager$IdleCallbackRunnable.cancel`

Differential Revision: D58356826
Titozzz pushed a commit that referenced this issue Jun 18, 2024
…44852)

Summary:
Pull Request resolved: #44852

This attempts to fix #44842 by capturing the accessed field in a new variable.
We don't have a way to reproduce this & this is a best guess fix.

Changelog:
[Android] [Fixed] - Tentative fix for NPE `JavaTimerManager$IdleCallbackRunnable.cancel`

Reviewed By: javache

Differential Revision: D58356826

fbshipit-source-id: d016df9a52f81a8d645a0a100c6bc6111841e24e
Titozzz pushed a commit that referenced this issue Jun 18, 2024
…44852)

Summary:
Pull Request resolved: #44852

This attempts to fix #44842 by capturing the accessed field in a new variable.
We don't have a way to reproduce this & this is a best guess fix.

Changelog:
[Android] [Fixed] - Tentative fix for NPE `JavaTimerManager$IdleCallbackRunnable.cancel`

Reviewed By: javache

Differential Revision: D58356826

fbshipit-source-id: d016df9a52f81a8d645a0a100c6bc6111841e24e
Titozzz pushed a commit that referenced this issue Jun 18, 2024
…44852)

Summary:
Pull Request resolved: #44852

This attempts to fix #44842 by capturing the accessed field in a new variable.
We don't have a way to reproduce this & this is a best guess fix.

Changelog:
[Android] [Fixed] - Tentative fix for NPE `JavaTimerManager$IdleCallbackRunnable.cancel`

Reviewed By: javache

Differential Revision: D58356826

fbshipit-source-id: d016df9a52f81a8d645a0a100c6bc6111841e24e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Newer Patch Available Resolution: PR Submitted A pull request with a fix has been provided.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants