Skip to content

Exception java.lang.NullPointerException: Parameter specified as non-null is null: method com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue, parameter runnable #54983

@mozzius

Description

@mozzius

Description

This appears to be a reappearance of #44842, to which a fix was added here: #44852

Much like that one, it's unclear how to reproduce (sorry)

In the Play Console crashes, we can see this:

Exception java.lang.NullPointerException: Parameter specified as non-null is null: method com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue, parameter runnable

This is our largest source of user-perceived crashes by a good margin.

While I don't have steps to reproduce or a reproducer, I do have have a fix that we rolled out at scale that seems to have worked - we rolled out a fix in version 1.112.0 and no longer see the issue (PR here: bluesky-social/social-app#9436)

Image

Filtering to the version with the experimental fix:

Image

What I think is going on, and the fix

The original fix was to capture the value of mCurrentIdleCallbackRunnable to a local variable before calling cancel():
cortinico@54df8fc

Then, the file got converted to Kotlin, where it has optional chaining syntax that handle it automatically.

currentIdleCallbackRunnable?.cancel()
currentIdleCallbackRunnable = IdleCallbackRunnable(frameTimeNanos)
reactApplicationContext.runOnJSQueueThread(currentIdleCallbackRunnable)

However, to my eyes, it seems the next two lines of code have the same problem as before:

currentIdleCallbackRunnable?.cancel() // yay, no longer crashes!
currentIdleCallbackRunnable = IdleCallbackRunnable(frameTimeNanos) // writes to currentIdleCallbackRunnable
reactApplicationContext.runOnJSQueueThread(currentIdleCallbackRunnable) // ‼️ reads from currentIdleCallbackRunnable

Since currentIdleCallbackRunnable apparently has a habit of being changed out from under you, we should probably do the same local capture thing as last time, to ensure we're passing the correct thing to runOnJSQueueThread

val idleCallbackRunnable = IdleCallbackRunnable(frameTimeNanos)
currentIdleCallbackRunnable = idleCallbackRunnable
reactApplicationContext.runOnJSQueueThread(idleCallbackRunnable)

This is the fix I put into production - I have opened a PR for it here. That said, I don't know if this is the correct fix - maybe a mutex or something is needed?

Steps to reproduce

Unknown

React Native Version

0.81.5

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info

System:
  OS: macOS 15.7
  CPU: (14) arm64 Apple M4 Pro
  Memory: 303.97 MB / 48.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.19.4
    path: ~/.nvm/versions/node/v20.19.4/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v20.19.4/bin/yarn
  npm:
    version: 10.8.2
    path: ~/.nvm/versions/node/v20.19.4/bin/npm
  Watchman:
    version: 2025.12.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.2
      - iOS 26.2
      - macOS 26.2
      - tvOS 26.2
      - visionOS 26.2
      - watchOS 26.2
  Android SDK:
    API Levels:
      - "29"
      - "33"
      - "34"
      - "35"
      - "36"
    Build Tools:
      - 30.0.3
      - 34.0.0
      - 35.0.0
      - 35.0.1
      - 36.0.0
    System Images:
      - android-29 | Google Play ARM 64 v8a
      - android-30 | Google APIs ARM 64 v8a
      - android-35 | Google Play ARM 64 v8a
      - android-36 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2025.1 AI-251.27812.49.2514.14217341
  Xcode:
    version: 26.2/17C52
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.17
    path: /usr/bin/javac
  Ruby:
    version: 2.7.6
    path: /Users/samuel/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.81.5
    wanted: 0.81.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

Exception java.lang.NullPointerException: Parameter specified as non-null is null: method com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue, parameter runnable
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue (Unknown Source:2)
  at com.facebook.react.bridge.ReactContext.runOnJSQueueThread (ReactContext.java:415)
  at com.facebook.react.modules.core.JavaTimerManager$IdleFrameCallback.doFrame (JavaTimerManager.kt:317)
  at com.facebook.react.modules.core.ReactChoreographer.frameCallback$lambda$1 (ReactChoreographer.kt:59)
  at com.facebook.react.modules.core.ReactChoreographer.$r8$lambda$nSkFhrr5T7rop_XKwzlLov4NLLw (Unknown Source)
  at com.facebook.react.modules.core.ReactChoreographer$$ExternalSyntheticLambda0.doFrame (D8$$SyntheticClass)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1229)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1239)
  at android.view.Choreographer.doCallbacks (Choreographer.java:899)
  at android.view.Choreographer.doFrame (Choreographer.java:827)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1214)
  at android.os.Handler.handleCallback (Handler.java:984)
  at android.os.Handler.dispatchMessage (Handler.java:104)
  at android.os.Looper.loopOnce (Looper.java:238)
  at android.os.Looper.loop (Looper.java:357)
  at android.app.ActivityThread.main (ActivityThread.java:8149)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:957)

MANDATORY Reproducer

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

Screenshots and Videos

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Author FeedbackNeeds: ReproThis issue could be improved with a clear list of steps to reproduce the issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions