From cc71f9c550864000dad148dfd2d72fe3e0fc6075 Mon Sep 17 00:00:00 2001 From: Nick Lefever Date: Mon, 11 Aug 2025 14:45:36 -0700 Subject: [PATCH] Create tryDispatchMountItems runnable only when needed (#53196) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53196 In the FabricUIManager, the runnable created for scheduled mounts is only used if currently running on the UI thread. With this diff the runnable only gets created when needed. Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D79969412 fbshipit-source-id: ee78890322af8580357389aad8357f7c0d18490f --- .../com/facebook/react/fabric/FabricUIManager.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index cb16e0b0ca2..078cc64ac7c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -935,14 +935,14 @@ public class FabricUIManager if (shouldSchedule) { Assertions.assertNotNull(mountItem, "MountItem is null"); mMountItemDispatcher.addMountItem(mountItem); - Runnable runnable = - new GuardedRunnable(mReactApplicationContext) { - @Override - public void runGuarded() { - mMountItemDispatcher.tryDispatchMountItems(); - } - }; if (UiThreadUtil.isOnUiThread()) { + Runnable runnable = + new GuardedRunnable(mReactApplicationContext) { + @Override + public void runGuarded() { + mMountItemDispatcher.tryDispatchMountItems(); + } + }; runnable.run(); } }