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:22:19 -07:00 коммит произвёл Facebook Github Bot
Родитель 20b4879dfd
Коммит 2a336f2b11
1 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -136,11 +136,13 @@ public class ReactChoreographer {
public synchronized void removeFrameCallback( public synchronized void removeFrameCallback(
CallbackType type, CallbackType type,
ChoreographerCompat.FrameCallback frameCallback) { ChoreographerCompat.FrameCallback frameCallback) {
if (mCallbackQueues[type.getOrder()].removeFirstOccurrence(frameCallback)) { synchronized (ReactChoreographer.this) {
mTotalCallbacks--; if (mCallbackQueues[type.getOrder()].removeFirstOccurrence(frameCallback)) {
maybeRemoveFrameCallback(); mTotalCallbacks--;
} else { maybeRemoveFrameCallback();
FLog.e(ReactConstants.TAG, "Tried to remove non-existent frame callback"); } else {
FLog.e(ReactConstants.TAG, "Tried to remove non-existent frame callback");
}
} }
} }