Skip to content

Commit 988bf16

Browse files
cortinicoTitozzz
authored andcommitted
Tentative fix for NPE JavaTimerManager$IdleCallbackRunnable.cancel (#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
1 parent f4b0fcb commit 988bf16

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ public void doFrame(long frameTimeNanos) {
9999
}
100100

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

106109
mCurrentIdleCallbackRunnable = new IdleCallbackRunnable(frameTimeNanos);

0 commit comments

Comments
 (0)