Move RuntimeScheduler initialisation to the start of the runtime

Summary:
Changelog: [internal]

RuntimeScheduler needs to be created and registered in the runtime before any JS is allowed to run. This diff moves the registration right after the runtime is initialised.

This diff removes funnelling of Fabric events through RuntimeScheduler. This will be added in subsequent diff to keep the complexity low.

Reviewed By: JoshuaGross

Differential Revision: D29131766

fbshipit-source-id: cbc650f6fbce95e4b9c2c9695e8e0aba5beac635
This commit is contained in:
Samuel Susla
2021-06-15 17:34:08 -07:00
committed by Facebook GitHub Bot
parent 741b4d4421
commit 18165367b0
7 changed files with 139 additions and 0 deletions
@@ -83,6 +83,7 @@ import com.facebook.react.devsupport.RedBoxHandler;
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
import com.facebook.react.devsupport.interfaces.DevSupportManager;
import com.facebook.react.devsupport.interfaces.PackagerStatusCallback;
import com.facebook.react.fabric.RuntimeSchedulerManager;
import com.facebook.react.modules.appearance.AppearanceModule;
import com.facebook.react.modules.appregistry.AppRegistry;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
@@ -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();