mirror of
https://github.com/status-im/react-native.git
synced 2025-02-23 22:58:19 +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);
|
minTimeLeftInFrameForNonBatchedOperationMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private UIImplementation(
|
UIImplementation(
|
||||||
ReactApplicationContext reactContext,
|
ReactApplicationContext reactContext,
|
||||||
ViewManagerRegistry viewManagers,
|
ViewManagerRegistry viewManagers,
|
||||||
EventDispatcher eventDispatcher,
|
EventDispatcher eventDispatcher,
|
||||||
|
@ -39,4 +39,16 @@ public class UIImplementationProvider {
|
|||||||
eventDispatcher,
|
eventDispatcher,
|
||||||
minTimeLeftInFrameForNonBatchedOperationMs);
|
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.bridge.WritableMap;
|
||||||
import com.facebook.react.common.MapBuilder;
|
import com.facebook.react.common.MapBuilder;
|
||||||
import com.facebook.react.common.ReactConstants;
|
import com.facebook.react.common.ReactConstants;
|
||||||
|
import com.facebook.react.common.annotations.VisibleForTesting;
|
||||||
import com.facebook.react.module.annotations.ReactModule;
|
import com.facebook.react.module.annotations.ReactModule;
|
||||||
import com.facebook.react.uimanager.common.MeasureSpecProvider;
|
import com.facebook.react.uimanager.common.MeasureSpecProvider;
|
||||||
import com.facebook.react.uimanager.common.SizeMonitoringFrameLayout;
|
import com.facebook.react.uimanager.common.SizeMonitoringFrameLayout;
|
||||||
@ -112,6 +113,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule
|
|||||||
private final EventDispatcher mEventDispatcher;
|
private final EventDispatcher mEventDispatcher;
|
||||||
private final Map<String, Object> mModuleConstants;
|
private final Map<String, Object> mModuleConstants;
|
||||||
private final Map<String, Object> mCustomDirectEvents;
|
private final Map<String, Object> mCustomDirectEvents;
|
||||||
|
private final ViewManagerRegistry mViewManagerRegistry;
|
||||||
private final UIImplementation mUIImplementation;
|
private final UIImplementation mUIImplementation;
|
||||||
private final MemoryTrimCallback mMemoryTrimCallback = new MemoryTrimCallback();
|
private final MemoryTrimCallback mMemoryTrimCallback = new MemoryTrimCallback();
|
||||||
private final List<UIManagerModuleListener> mListeners = new ArrayList<>();
|
private final List<UIManagerModuleListener> mListeners = new ArrayList<>();
|
||||||
@ -155,10 +157,11 @@ public class UIManagerModule extends ReactContextBaseJavaModule
|
|||||||
mEventDispatcher = new EventDispatcher(reactContext);
|
mEventDispatcher = new EventDispatcher(reactContext);
|
||||||
mModuleConstants = createConstants(viewManagerResolver);
|
mModuleConstants = createConstants(viewManagerResolver);
|
||||||
mCustomDirectEvents = UIManagerModuleConstants.getDirectEventTypeConstants();
|
mCustomDirectEvents = UIManagerModuleConstants.getDirectEventTypeConstants();
|
||||||
|
mViewManagerRegistry = new ViewManagerRegistry(viewManagerResolver);
|
||||||
mUIImplementation =
|
mUIImplementation =
|
||||||
uiImplementationProvider.createUIImplementation(
|
uiImplementationProvider.createUIImplementation(
|
||||||
reactContext,
|
reactContext,
|
||||||
viewManagerResolver,
|
mViewManagerRegistry,
|
||||||
mEventDispatcher,
|
mEventDispatcher,
|
||||||
minTimeLeftInFrameForNonBatchedOperationMs);
|
minTimeLeftInFrameForNonBatchedOperationMs);
|
||||||
|
|
||||||
@ -176,10 +179,11 @@ public class UIManagerModule extends ReactContextBaseJavaModule
|
|||||||
mEventDispatcher = new EventDispatcher(reactContext);
|
mEventDispatcher = new EventDispatcher(reactContext);
|
||||||
mCustomDirectEvents = MapBuilder.newHashMap();
|
mCustomDirectEvents = MapBuilder.newHashMap();
|
||||||
mModuleConstants = createConstants(viewManagersList, null, mCustomDirectEvents);
|
mModuleConstants = createConstants(viewManagersList, null, mCustomDirectEvents);
|
||||||
|
mViewManagerRegistry = new ViewManagerRegistry(viewManagersList);
|
||||||
mUIImplementation =
|
mUIImplementation =
|
||||||
uiImplementationProvider.createUIImplementation(
|
uiImplementationProvider.createUIImplementation(
|
||||||
reactContext,
|
reactContext,
|
||||||
viewManagersList,
|
mViewManagerRegistry,
|
||||||
mEventDispatcher,
|
mEventDispatcher,
|
||||||
minTimeLeftInFrameForNonBatchedOperationMs);
|
minTimeLeftInFrameForNonBatchedOperationMs);
|
||||||
|
|
||||||
@ -237,6 +241,15 @@ public class UIManagerModule extends ReactContextBaseJavaModule
|
|||||||
ViewManagerPropertyUpdater.clear();
|
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) {
|
private static Map<String, Object> createConstants(ViewManagerResolver viewManagerResolver) {
|
||||||
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_START);
|
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_START);
|
||||||
SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants")
|
SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user