Allow ReactChoreographer to execute a FrameCallback that removes another FrameCallback from the mCallbackQueues

Summary: This diff extends the ReactChoreographer to allow the execution of FrameCallbacks that removes another FrameCallback from the mCallbackQueues.

Reviewed By: ejanzer

Differential Revision: D15891759

fbshipit-source-id: 62bc2b6afac45c50ac18771b0821742b4f7fc10e
This commit is contained in:
David Vacca
2019-06-24 19:08:39 -07:00
committed by Facebook Github Bot
parent 2bd503285e
commit 89bf3d8b38
@@ -167,10 +167,16 @@ public class ReactChoreographer {
synchronized (mCallbackQueuesLock) {
mHasPostedCallback = false;
for (int i = 0; i < mCallbackQueues.length; i++) {
int initialLength = mCallbackQueues[i].size();
ArrayDeque<ChoreographerCompat.FrameCallback> callbackQueue = mCallbackQueues[i];
int initialLength = callbackQueue.size();
for (int callback = 0; callback < initialLength; callback++) {
mCallbackQueues[i].removeFirst().doFrame(frameTimeNanos);
mTotalCallbacks--;
ChoreographerCompat.FrameCallback frameCallback = callbackQueue.pollFirst();
if (frameCallback != null) {
frameCallback.doFrame(frameTimeNanos);
mTotalCallbacks--;
} else {
FLog.e(ReactConstants.TAG, "Tried to execute non-existent frame callback");
}
}
}
maybeRemoveFrameCallback();