mirror of
https://github.com/status-im/react-native.git
synced 2025-02-23 06:38:13 +00:00
Reuse ViewManagerRegistry between UIManagerModule and FabricUIManager
Summary: This diff reuses the ViewManager registry between UIManagerModule and Fabric, previously View Managers were being initialized twice (one for each UIManager), increasing Fabric TTI by ~77ms Reviewed By: shergin Differential Revision: D13640912 fbshipit-source-id: d7a9591084c66e4a2fc2384b2dae1b7fc5a228d0
This commit is contained in:
parent
cb14b06309
commit
adc1a95a3b
@ -87,7 +87,7 @@ public class UIImplementation {
|
||||
minTimeLeftInFrameForNonBatchedOperationMs);
|
||||
}
|
||||
|
||||
private UIImplementation(
|
||||
UIImplementation(
|
||||
ReactApplicationContext reactContext,
|
||||
ViewManagerRegistry viewManagers,
|
||||
EventDispatcher eventDispatcher,
|
||||
|
@ -39,4 +39,16 @@ public class UIImplementationProvider {
|
||||
eventDispatcher,
|
||||
minTimeLeftInFrameForNonBatchedOperationMs);
|
||||
}
|
||||
|
||||
UIImplementation createUIImplementation(
|
||||
ReactApplicationContext reactContext,
|
||||
ViewManagerRegistry viewManagerRegistry,
|
||||
EventDispatcher eventDispatcher,
|
||||
int minTimeLeftInFrameForNonBatchedOperationMs) {
|
||||
return new UIImplementation(
|
||||
reactContext,
|
||||
viewManagerRegistry,
|
||||
eventDispatcher,
|
||||
minTimeLeftInFrameForNonBatchedOperationMs);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ import com.facebook.react.bridge.UIManager;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
import com.facebook.react.common.annotations.VisibleForTesting;
|
||||
import com.facebook.react.module.annotations.ReactModule;
|
||||
import com.facebook.react.uimanager.common.MeasureSpecProvider;
|
||||
import com.facebook.react.uimanager.common.SizeMonitoringFrameLayout;
|
||||
@ -112,6 +113,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule
|
||||
private final EventDispatcher mEventDispatcher;
|
||||
private final Map<String, Object> mModuleConstants;
|
||||
private final Map<String, Object> mCustomDirectEvents;
|
||||
private final ViewManagerRegistry mViewManagerRegistry;
|
||||
private final UIImplementation mUIImplementation;
|
||||
private final MemoryTrimCallback mMemoryTrimCallback = new MemoryTrimCallback();
|
||||
private final List<UIManagerModuleListener> mListeners = new ArrayList<>();
|
||||
@ -155,10 +157,11 @@ public class UIManagerModule extends ReactContextBaseJavaModule
|
||||
mEventDispatcher = new EventDispatcher(reactContext);
|
||||
mModuleConstants = createConstants(viewManagerResolver);
|
||||
mCustomDirectEvents = UIManagerModuleConstants.getDirectEventTypeConstants();
|
||||
mViewManagerRegistry = new ViewManagerRegistry(viewManagerResolver);
|
||||
mUIImplementation =
|
||||
uiImplementationProvider.createUIImplementation(
|
||||
reactContext,
|
||||
viewManagerResolver,
|
||||
mViewManagerRegistry,
|
||||
mEventDispatcher,
|
||||
minTimeLeftInFrameForNonBatchedOperationMs);
|
||||
|
||||
@ -176,10 +179,11 @@ public class UIManagerModule extends ReactContextBaseJavaModule
|
||||
mEventDispatcher = new EventDispatcher(reactContext);
|
||||
mCustomDirectEvents = MapBuilder.newHashMap();
|
||||
mModuleConstants = createConstants(viewManagersList, null, mCustomDirectEvents);
|
||||
mViewManagerRegistry = new ViewManagerRegistry(viewManagersList);
|
||||
mUIImplementation =
|
||||
uiImplementationProvider.createUIImplementation(
|
||||
reactContext,
|
||||
viewManagersList,
|
||||
mViewManagerRegistry,
|
||||
mEventDispatcher,
|
||||
minTimeLeftInFrameForNonBatchedOperationMs);
|
||||
|
||||
@ -237,6 +241,15 @@ public class UIManagerModule extends ReactContextBaseJavaModule
|
||||
ViewManagerPropertyUpdater.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is intended to reuse the {@link ViewManagerRegistry} with FabricUIManager.
|
||||
* Do not use this method as this will be removed in the near future.
|
||||
*/
|
||||
@Deprecated
|
||||
public ViewManagerRegistry getViewManagerRegistry_DO_NOT_USE() {
|
||||
return mViewManagerRegistry;
|
||||
}
|
||||
|
||||
private static Map<String, Object> createConstants(ViewManagerResolver viewManagerResolver) {
|
||||
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_START);
|
||||
SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants")
|
||||
|
Loading…
x
Reference in New Issue
Block a user