Eager load Fabric classes

Summary: Eager load classes used by Fabric. This is a temporary change that will be reverted in the near future

Reviewed By: shergin

Differential Revision: D13747454

fbshipit-source-id: 8ceb21f51982bcfcaa005dcc2ad9b457f7211795
This commit is contained in:
David Vacca 2019-01-22 11:35:09 -08:00 committed by Facebook Github Bot
parent fe6f6cd46f
commit b718d33721
4 changed files with 56 additions and 6 deletions

View File

@ -1,15 +1,33 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.react.fabric;
import com.facebook.react.fabric.jsi.Binding;
import com.facebook.react.fabric.jsi.ComponentFactoryDelegate;
import com.facebook.react.fabric.jsi.EventBeatManager;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.bridge.JSIModuleProvider;
import com.facebook.react.bridge.JavaScriptContextHolder;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.UIManager;
import com.facebook.react.bridge.queue.MessageQueueThread;
import com.facebook.react.fabric.jsi.Binding;
import com.facebook.react.fabric.jsi.ComponentFactoryDelegate;
import com.facebook.react.fabric.jsi.ComponentRegistry;
import com.facebook.react.fabric.jsi.EventBeatManager;
import com.facebook.react.fabric.jsi.EventEmitterWrapper;
import com.facebook.react.fabric.jsi.FabricSoLoader;
import com.facebook.react.fabric.mounting.ContextBasedViewPool;
import com.facebook.react.fabric.mounting.LayoutMetricsConversions;
import com.facebook.react.fabric.mounting.MountingManager;
import com.facebook.react.fabric.mounting.ViewPool;
import com.facebook.react.fabric.mounting.mountitems.BatchMountItem;
import com.facebook.react.fabric.mounting.mountitems.CreateMountItem;
import com.facebook.react.fabric.mounting.mountitems.DeleteMountItem;
import com.facebook.react.fabric.mounting.mountitems.DispatchCommandMountItem;
import com.facebook.react.fabric.mounting.mountitems.InsertMountItem;
import com.facebook.react.fabric.mounting.mountitems.MountItem;
import com.facebook.react.fabric.mounting.mountitems.RemoveMountItem;
import com.facebook.react.fabric.mounting.mountitems.UpdateEventEmitterMountItem;
import com.facebook.react.fabric.mounting.mountitems.UpdateLayoutMountItem;
import com.facebook.react.fabric.mounting.mountitems.UpdateLocalDataMountItem;
import com.facebook.react.fabric.mounting.mountitems.UpdatePropsMountItem;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.systrace.Systrace;
@ -40,6 +58,8 @@ public class FabricJSIModuleProvider implements JSIModuleProvider<UIManager> {
Systrace.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.registerBinding");
final Binding binding = new Binding();
// TODO T31905686: remove this call
loadClasses();
MessageQueueThread jsMessageQueueThread =
mReactApplicationContext
.getCatalystInstance()
@ -66,4 +86,33 @@ public class FabricJSIModuleProvider implements JSIModuleProvider<UIManager> {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
return fabricUIManager;
}
// TODO T31905686: eager load Fabric classes, this is temporary and it will be removed
// in the near future
private static void loadClasses() {
FabricEventEmitter.class.getClass();
FabricUIManager.class.getClass();
GuardedFrameCallback.class.getClass();
BatchMountItem.class.getClass();
CreateMountItem.class.getClass();
DeleteMountItem.class.getClass();
DispatchCommandMountItem.class.getClass();
InsertMountItem.class.getClass();
MountItem.class.getClass();
RemoveMountItem.class.getClass();
UpdateEventEmitterMountItem.class.getClass();
UpdateLayoutMountItem.class.getClass();
UpdateLocalDataMountItem.class.getClass();
UpdatePropsMountItem.class.getClass();
ContextBasedViewPool.class.getClass();
LayoutMetricsConversions.class.getClass();
MountingManager.class.getClass();
ViewPool.class.getClass();
Binding.class.getClass();
ComponentFactoryDelegate.class.getClass();
ComponentRegistry.class.getClass();
EventBeatManager.class.getClass();
EventEmitterWrapper.class.getClass();
FabricSoLoader.class.getClass();
}
}

View File

@ -14,7 +14,7 @@ import com.facebook.react.uimanager.ViewManagerRegistry;
import java.util.WeakHashMap;
/** Class that provides pool for views based on {@link ThemedReactContext}. */
final class ContextBasedViewPool {
public final class ContextBasedViewPool {
private final WeakHashMap<ThemedReactContext, ViewPool> mContextViewPoolHashMap =
new WeakHashMap<>();
private final ViewManagerRegistry mViewManagerRegistry;

View File

@ -15,7 +15,7 @@ import com.facebook.react.uimanager.ViewManagerRegistry;
import java.util.HashMap;
import java.util.Map;
final class ViewPool {
public final class ViewPool {
private static final int POOL_SIZE = 512;
private final Map<String, ClearableSynchronizedPool<View>> mViewPool = new HashMap<>();
private final ViewManagerRegistry mViewManagerRegistry;

View File

@ -317,7 +317,8 @@ public class TextLayoutManager {
return YogaMeasureOutput.make(PixelUtil.toSPFromPixel(width), PixelUtil.toSPFromPixel(height));
}
private static class SetSpanOperation {
// TODO T31905686: This class should be private
public static class SetSpanOperation {
protected int start, end;
protected ReactSpan what;