diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 1d49251377d..6d745f384d7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -114,6 +114,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule private volatile int mViewManagerConstantsCacheSize; private int mBatchId = 0; + private int mNumRootViews = 0; @SuppressWarnings("deprecated") public UIManagerModule( @@ -442,6 +443,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule -1); mUIImplementation.registerRootView(rootView, tag, themedRootContext); + mNumRootViews++; Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); return tag; } @@ -465,6 +467,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule @ReactMethod public void removeRootView(int rootViewTag) { mUIImplementation.removeRootView(rootViewTag); + mNumRootViews--; } public void updateNodeSize(int nodeViewTag, int newWidth, int newHeight) { @@ -805,7 +808,12 @@ public class UIManagerModule extends ReactContextBaseJavaModule listener.willDispatchViewUpdates(this); } try { - mUIImplementation.dispatchViewUpdates(batchId); + // If there are no RootViews registered, there will be no View updates to dispatch. + // This is a hack to prevent this from being called when Fabric is used everywhere. + // This should no longer be necessary in Bridgeless Mode. + if (mNumRootViews > 0) { + mUIImplementation.dispatchViewUpdates(batchId); + } } finally { Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); }