add experiment for running the JS on view creation

Summary:
Changelog: [Internal]

# Context

Whilst looking at Marketplace Loom traces, ShikaSD made the remark that we could potentially start the JS work much earlier instead of waiting for the View.onMeasure call, a behaviour that is already built-in Venice.

Reviewed By: ShikaSD

Differential Revision: D32559505

fbshipit-source-id: cc6337955ad2b6a6581a0347f1f976679eaca54d
This commit is contained in:
Jimmy Lai 2021-11-19 07:33:22 -08:00 коммит произвёл Facebook GitHub Bot
Родитель db21584ba0
Коммит 2dd33b16df
2 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -44,6 +44,7 @@ import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.modules.appregistry.AppRegistry;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.facebook.react.modules.deviceinfo.DeviceInfoModule;
@ -439,7 +440,11 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
mInitialUITemplate = initialUITemplate;
mReactInstanceManager.createReactContextInBackground();
// if in this experiment, we initialize the root earlier in startReactApplication
// instead of waiting for the initial measure
if (ReactFeatureFlags.enableEagerRootViewAttachment) {
attachToReactInstanceManager();
}
} finally {
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}

Просмотреть файл

@ -80,6 +80,9 @@ public class ReactFeatureFlags {
/** Feature flag to configure eager initialization of MapBuffer So file */
public static boolean enableEagerInitializeMapBufferSoFile = false;
/** Feature flag to configure eager attachment of the root view/initialisation of the JS code */
public static boolean enableEagerRootViewAttachment = false;
private static boolean mapBufferSerializationEnabled = false;
/** Enables or disables MapBuffer Serialization */