Skip to content

Commit

Permalink
Tentative fix for NPE JavaTimerManager$IdleCallbackRunnable.cancel (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
cortinico authored and Titozzz committed Jun 18, 2024
1 parent 78723a4 commit c67fbeb
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ public void doFrame(long frameTimeNanos) {
}

// If the JS thread is busy for multiple frames we cancel any other pending runnable.
if (mCurrentIdleCallbackRunnable != null) {
mCurrentIdleCallbackRunnable.cancel();
// We also capture the idleCallbackRunnable to tentatively fix:
// https://github.com/facebook/react-native/issues/44842
IdleCallbackRunnable idleCallbackRunnable = mCurrentIdleCallbackRunnable;
if (idleCallbackRunnable != null) {
idleCallbackRunnable.cancel();
}

mCurrentIdleCallbackRunnable = new IdleCallbackRunnable(frameTimeNanos);
Expand Down

0 comments on commit c67fbeb

Please sign in to comment.