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
This commit is contained in:
David Vacca
2019-03-26 10:38:42 -07:00
committed by Facebook Github Bot
parent 20b4879dfd
commit 2a336f2b11
@@ -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");
}
}
}