From 0c9de82f91ca80b8903a7eec105183e9351c34bc Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 30 Jun 2022 10:29:53 -0700 Subject: [PATCH] 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 --- .../facebook/react/fabric/FabricUIManager.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index e8ab3bdcc16..96d624e0d2c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -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); } } }