From 2a336f2b11cea88a118e2521eef1de7d48211c97 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 26 Mar 2019 10:22:19 -0700 Subject: [PATCH] Fix NoSuchElementException in ReactChoreographerDispatcher.doFrame Summary: This diff fixes a NoSuchElementException that was being thrown at ReactChoreographerDispatcher.doFrame(). The root cause was a lack of syncronization in removeFrameCallback(). Reviewed By: shergin Differential Revision: D14619386 fbshipit-source-id: 80bc9e44866218d2a8703b3186f6958c145f260b --- .../react/modules/core/ReactChoreographer.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/core/ReactChoreographer.java b/ReactAndroid/src/main/java/com/facebook/react/modules/core/ReactChoreographer.java index d937d9eeb0e..283556cea15 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/core/ReactChoreographer.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/core/ReactChoreographer.java @@ -136,11 +136,13 @@ public class ReactChoreographer { public synchronized void removeFrameCallback( CallbackType type, ChoreographerCompat.FrameCallback frameCallback) { - if (mCallbackQueues[type.getOrder()].removeFirstOccurrence(frameCallback)) { - mTotalCallbacks--; - maybeRemoveFrameCallback(); - } else { - FLog.e(ReactConstants.TAG, "Tried to remove non-existent frame callback"); + synchronized (ReactChoreographer.this) { + if (mCallbackQueues[type.getOrder()].removeFirstOccurrence(frameCallback)) { + mTotalCallbacks--; + maybeRemoveFrameCallback(); + } else { + FLog.e(ReactConstants.TAG, "Tried to remove non-existent frame callback"); + } } }