From 279fb3eedce50b85662279760c26a780226c6b95 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 16 Jun 2021 08:39:31 -0700 Subject: [PATCH] Back out "Move RuntimeScheduler initialisation to the start of the runtime" Summary: Changelog: [internal] Original commit changeset: cbc650f6fbce Fix app size regression. Reviewed By: julian-krzeminski Differential Revision: D29162397 fbshipit-source-id: 54b344c2da631aaa704fd640cdb2a71239ea754f --- .../src/main/java/com/facebook/react/BUCK | 1 - .../facebook/react/ReactInstanceManager.java | 7 --- .../react/config/ReactFeatureFlags.java | 2 - .../react/fabric/RuntimeSchedulerManager.java | 41 ----------------- .../com/facebook/react/fabric/jni/OnLoad.cpp | 2 - .../fabric/jni/RuntimeSchedulerManager.cpp | 46 ------------------- .../fabric/jni/RuntimeSchedulerManager.h | 40 ---------------- 7 files changed, 139 deletions(-) delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/fabric/RuntimeSchedulerManager.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/fabric/jni/RuntimeSchedulerManager.cpp delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/fabric/jni/RuntimeSchedulerManager.h diff --git a/ReactAndroid/src/main/java/com/facebook/react/BUCK b/ReactAndroid/src/main/java/com/facebook/react/BUCK index 669209d2e833cc..eebb0432a68761 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/BUCK @@ -39,7 +39,6 @@ rn_android_library( react_native_target("java/com/facebook/react/modules/bundleloader:bundleloader"), react_native_target("java/com/facebook/react/modules/debug:debug"), react_native_target("java/com/facebook/react/modules/fabric:fabric"), - react_native_target("java/com/facebook/react/fabric:fabric"), react_native_target("java/com/facebook/react/modules/debug:interfaces"), react_native_target("java/com/facebook/react/modules/deviceinfo:deviceinfo"), react_native_target("java/com/facebook/react/modules/systeminfo:systeminfo"), diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index 027cfc49f59824..b46b1b71b2ce0e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -83,7 +83,6 @@ 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; @@ -163,7 +162,6 @@ public interface ReactInstanceEventListener { 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; @@ -720,7 +718,6 @@ public void destroy() { mViewManagerNames = null; } mComponentNameResolverManager = null; - mRuntimeSchedulerManager = null; FLog.d(ReactConstants.TAG, "ReactInstanceManager has been destroyed"); } @@ -1353,10 +1350,6 @@ public String[] getComponentNames() { }); 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(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index b8a5d16069db5a..f5b432050992bf 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -44,8 +44,6 @@ public class ReactFeatureFlags { /** Enables Static ViewConfig in RN Android native code. */ public static boolean enableExperimentalStaticViewConfigs = false; - public static boolean enableRuntimeScheduler = false; - /** Enables a more aggressive cleanup during destruction of ReactContext */ public static boolean enableReactContextCleanupFix = false; diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/RuntimeSchedulerManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/RuntimeSchedulerManager.java deleted file mode 100644 index a188792fb3f9b4..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/RuntimeSchedulerManager.java +++ /dev/null @@ -1,41 +0,0 @@ -// (c) Facebook, Inc. and its affiliates. Confidential and proprietary. - -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.fabric; - -import com.facebook.jni.HybridData; -import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.proguard.annotations.DoNotStripAny; -import com.facebook.react.bridge.RuntimeExecutor; -import com.facebook.soloader.SoLoader; - -@DoNotStripAny -public class RuntimeSchedulerManager { - - static { - staticInit(); - } - - @DoNotStrip - @SuppressWarnings("unused") - private final HybridData mHybridData; - - public RuntimeSchedulerManager(RuntimeExecutor runtimeExecutor) { - mHybridData = initHybrid(runtimeExecutor); - installJSIBindings(); - } - - private native HybridData initHybrid(RuntimeExecutor runtimeExecutor); - - private native void installJSIBindings(); - - private static void staticInit() { - SoLoader.loadLibrary("fabricjni"); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/OnLoad.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/OnLoad.cpp index bdf8ea52097549..61fcec3d1c9885 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/OnLoad.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/OnLoad.cpp @@ -12,7 +12,6 @@ #include "CoreComponentsRegistry.h" #include "EventBeatManager.h" #include "EventEmitterWrapper.h" -#include "RuntimeSchedulerManager.h" #include "StateWrapperImpl.h" #include "SurfaceHandlerBinding.h" @@ -25,6 +24,5 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) { facebook::react::ComponentFactory::registerNatives(); facebook::react::CoreComponentsRegistry::registerNatives(); facebook::react::SurfaceHandlerBinding::registerNatives(); - facebook::react::RuntimeSchedulerManager::registerNatives(); }); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/RuntimeSchedulerManager.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/RuntimeSchedulerManager.cpp deleted file mode 100644 index 2b0d89337035ca..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/RuntimeSchedulerManager.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include -#include -#include -#include - -#include "RuntimeSchedulerManager.h" - -namespace facebook { -namespace react { - -RuntimeSchedulerManager::RuntimeSchedulerManager( - RuntimeExecutor runtimeExecutor) - : runtimeExecutor_(runtimeExecutor) {} - -jni::local_ref -RuntimeSchedulerManager::initHybrid( - jni::alias_ref, - jni::alias_ref runtimeExecutor) { - return makeCxxInstance(runtimeExecutor->cthis()->get()); -} - -void RuntimeSchedulerManager::registerNatives() { - registerHybrid({ - makeNativeMethod("initHybrid", RuntimeSchedulerManager::initHybrid), - makeNativeMethod( - "installJSIBindings", RuntimeSchedulerManager::installJSIBindings), - }); -} - -void RuntimeSchedulerManager::installJSIBindings() { - runtimeExecutor_([runtimeExecutor = runtimeExecutor_](jsi::Runtime &runtime) { - auto runtimeScheduler = std::make_shared(runtimeExecutor); - RuntimeSchedulerBinding::createAndInstallIfNeeded( - runtime, runtimeScheduler); - }); -} - -} // namespace react -} // namespace facebook diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/RuntimeSchedulerManager.h b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/RuntimeSchedulerManager.h deleted file mode 100644 index 3c4112e026873a..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/RuntimeSchedulerManager.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include -#include -#include -#include - -namespace facebook { -namespace react { - -class RuntimeSchedulerManager - : public facebook::jni::HybridClass { - public: - static auto constexpr kJavaDescriptor = - "Lcom/facebook/react/fabric/RuntimeSchedulerManager;"; - - static facebook::jni::local_ref initHybrid( - jni::alias_ref, - facebook::jni::alias_ref runtimeExecutor); - - static void registerNatives(); - - private: - friend HybridBase; - RuntimeExecutor runtimeExecutor_; - - void installJSIBindings(); - - explicit RuntimeSchedulerManager(RuntimeExecutor runtimeExecutor); -}; - -} // namespace react -} // namespace facebook