mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Non-Fabric UIModuleManager should not flush View updates if there are no non-Fabric views
Summary: In Fabric, we currently incur the cost of (frequently!) flushing non-Fabric UI updates, even if there are no non-Fabric views. For now it is still possible to run both renderers at the same time, so we still largely continue to use the non-Fabric path, but only use UIImplementation if there is actually a RootView being managed outside of Fabric. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D29724538 fbshipit-source-id: 0f1148870c04ca9aaed0edfd6b5c55a3756a2bd7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4f38cb30b8
commit
9a78121ed3
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user