Move RuntimeScheduler initialisation to the start of the runtime

Summary:
Changelog: [internal]

Reland of D29131766 (https://github.com/facebook/react-native/commit/18165367b0347fc46cd52a6ac00afcf62d05cb30) which had to reverted because it caused binary size regression in instagram.

Size check for `automation_instagram_stablesize_release` and `automation_igtv_release`
{F626711916}

Reviewed By: JoshuaGross

Differential Revision: D29263302

fbshipit-source-id: cc8f5609ebaed9ddf666f7c57cdbf3dbf77a8f78
This commit is contained in:
Samuel Susla
2021-06-21 16:13:51 -07:00
committed by Facebook GitHub Bot
parent ad0ccac0d6
commit 130b0f69ee
12 changed files with 241 additions and 3 deletions
@@ -91,6 +91,7 @@ import com.facebook.react.modules.core.ReactChoreographer;
import com.facebook.react.modules.debug.interfaces.DeveloperSettings;
import com.facebook.react.modules.fabric.ReactFabric;
import com.facebook.react.packagerconnection.RequestHandler;
import com.facebook.react.runtimescheduler.RuntimeSchedulerManager;
import com.facebook.react.surface.ReactStage;
import com.facebook.react.turbomodule.core.TurboModuleManager;
import com.facebook.react.turbomodule.core.TurboModuleManagerDelegate;
@@ -162,6 +163,7 @@ public class ReactInstanceManager {
private final DevSupportManager mDevSupportManager;
private final boolean mUseDeveloperSupport;
private @Nullable ComponentNameResolverManager mComponentNameResolverManager;
private @Nullable RuntimeSchedulerManager mRuntimeSchedulerManager;
private final @Nullable NotThreadSafeBridgeIdleDebugListener mBridgeIdleDebugListener;
private final Object mReactContextLock = new Object();
private @Nullable volatile ReactContext mCurrentReactContext;
@@ -718,6 +720,7 @@ public class ReactInstanceManager {
mViewManagerNames = null;
}
mComponentNameResolverManager = null;
mRuntimeSchedulerManager = null;
FLog.d(ReactConstants.TAG, "ReactInstanceManager has been destroyed");
}
@@ -1350,6 +1353,10 @@ public class ReactInstanceManager {
});
catalystInstance.setGlobalVariable("__fbStaticViewConfig", "true");
}
if (ReactFeatureFlags.enableRuntimeScheduler) {
mRuntimeSchedulerManager = new RuntimeSchedulerManager(catalystInstance.getRuntimeExecutor());
}
ReactMarker.logMarker(ReactMarkerConstants.PRE_RUN_JS_BUNDLE_START);
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "runJSBundle");
catalystInstance.runJSBundle();