Followup to Early Schedule MountItem Execution

Summary:
The initial version of this would result in LayoutAnimations running potentially much faster than 60FPS (incorrectly). Resolve by calling tryDispatchMountItems directly instead of the frame callback runner.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D37543693

fbshipit-source-id: 91dbd961ecc155221c84148cb6b252a4aac9ec91
This commit is contained in:
Joshua Gross
2022-06-30 10:29:53 -07:00
committed by Facebook GitHub Bot
parent 2fb6a3393d
commit 0c9de82f91
@@ -811,9 +811,15 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
if (shouldSchedule) {
mMountItemDispatcher.addMountItem(mountItem);
Runnable runnable =
new Runnable() {
@Override
public void run() {
mMountItemDispatcher.tryDispatchMountItems();
}
};
if (UiThreadUtil.isOnUiThread()) {
// We only read these flags on the UI thread.
mMountItemDispatcher.tryDispatchMountItems();
runnable.run();
} else {
// The Choreographer will dispatch any mount items,
// but it only gets called at the /beginning/ of the
@@ -826,13 +832,7 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
// the PreMountItems that we need to process at a lower
// priority.
if (ReactFeatureFlags.enableEarlyScheduledMountItemExecution) {
UiThreadUtil.runOnUiThread(
new Runnable() {
@Override
public void run() {
mDispatchUIFrameCallback.doFrameGuarded(System.nanoTime());
}
});
UiThreadUtil.runOnUiThread(runnable);
}
}
}