Skip to content

Commit 2dd33b1

Browse files
Jimmy Laifacebook-github-bot
authored andcommitted
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
1 parent db21584 commit 2dd33b1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import com.facebook.react.bridge.WritableMap;
4545
import com.facebook.react.bridge.WritableNativeMap;
4646
import com.facebook.react.common.annotations.VisibleForTesting;
47+
import com.facebook.react.config.ReactFeatureFlags;
4748
import com.facebook.react.modules.appregistry.AppRegistry;
4849
import com.facebook.react.modules.core.DeviceEventManagerModule;
4950
import com.facebook.react.modules.deviceinfo.DeviceInfoModule;
@@ -439,7 +440,11 @@ public void startReactApplication(
439440
mInitialUITemplate = initialUITemplate;
440441

441442
mReactInstanceManager.createReactContextInBackground();
442-
443+
// if in this experiment, we initialize the root earlier in startReactApplication
444+
// instead of waiting for the initial measure
445+
if (ReactFeatureFlags.enableEagerRootViewAttachment) {
446+
attachToReactInstanceManager();
447+
}
443448
} finally {
444449
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
445450
}

ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ public class ReactFeatureFlags {
8080
/** Feature flag to configure eager initialization of MapBuffer So file */
8181
public static boolean enableEagerInitializeMapBufferSoFile = false;
8282

83+
/** Feature flag to configure eager attachment of the root view/initialisation of the JS code */
84+
public static boolean enableEagerRootViewAttachment = false;
85+
8386
private static boolean mapBufferSerializationEnabled = false;
8487

8588
/** Enables or disables MapBuffer Serialization */

0 commit comments

Comments
 (0)