Skip to content

Commit

Permalink
Remove redundant Android runtime scheduler mobile config flags
Browse files Browse the repository at this point in the history
Summary:
changelog: [internal]

Remove features flags for enabling RuntimeScheduler and RuntimeScheduler+TM to simplify setup.

Reviewed By: mdvacca

Differential Revision: D37912783

fbshipit-source-id: 1a24720dec3cf06067bf523d72f0919731a91b72
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Jul 20, 2022
1 parent 8a33b75 commit 2b57b74
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ public String toString() {
// C++ parts
private final HybridData mHybridData;

private static native HybridData initHybrid(
boolean enableRuntimeScheduler, boolean enableRuntimeSchedulerInTurboModule);
private static native HybridData initHybrid();

public native CallInvokerHolderImpl getJSCallInvokerHolder();

Expand All @@ -124,15 +123,7 @@ private CatalystInstanceImpl(
FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge.");
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createCatalystInstanceImpl");

if (ReactFeatureFlags.enableRuntimeSchedulerInTurboModule
&& !ReactFeatureFlags.enableRuntimeScheduler) {
Assertions.assertUnreachable();
}

mHybridData =
initHybrid(
ReactFeatureFlags.enableRuntimeScheduler,
ReactFeatureFlags.enableRuntimeSchedulerInTurboModule);
mHybridData = initHybrid();

mReactQueueConfiguration =
ReactQueueConfigurationImpl.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ public class ReactFeatureFlags {
/** This feature flag enables logs for Fabric */
public static boolean enableFabricLogs = false;

public static boolean enableRuntimeScheduler = false;

public static boolean enableRuntimeSchedulerInTurboModule = false;

/** Feature flag to configure eager attachment of the root view/initialisation of the JS code */
public static boolean enableEagerRootViewAttachment = false;

Expand Down
36 changes: 11 additions & 25 deletions ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,12 @@ class JInstanceCallback : public InstanceCallback {
} // namespace

jni::local_ref<CatalystInstanceImpl::jhybriddata>
CatalystInstanceImpl::initHybrid(
jni::alias_ref<jclass>,
bool enableRuntimeScheduler,
bool enableRuntimeSchedulerInTurboModule) {
return makeCxxInstance(
enableRuntimeScheduler, enableRuntimeSchedulerInTurboModule);
CatalystInstanceImpl::initHybrid(jni::alias_ref<jclass>) {
return makeCxxInstance();
}

CatalystInstanceImpl::CatalystInstanceImpl(
bool enableRuntimeScheduler,
bool enableRuntimeSchedulerInTurboModule)
: instance_(std::make_unique<Instance>()),
enableRuntimeScheduler_(enableRuntimeScheduler),
enableRuntimeSchedulerInTurboModule_(
enableRuntimeScheduler && enableRuntimeSchedulerInTurboModule) {}
CatalystInstanceImpl::CatalystInstanceImpl()
: instance_(std::make_unique<Instance>()) {}

void CatalystInstanceImpl::warnOnLegacyNativeModuleSystemUse() {
CxxNativeModule::setShouldWarnOnUse(true);
Expand Down Expand Up @@ -382,17 +373,12 @@ void CatalystInstanceImpl::handleMemoryPressure(int pressureLevel) {
jni::alias_ref<CallInvokerHolder::javaobject>
CatalystInstanceImpl::getJSCallInvokerHolder() {
if (!jsCallInvokerHolder_) {
if (enableRuntimeSchedulerInTurboModule_) {
auto runtimeScheduler = getRuntimeScheduler();
auto runtimeSchedulerCallInvoker =
std::make_shared<RuntimeSchedulerCallInvoker>(
runtimeScheduler->cthis()->get());
jsCallInvokerHolder_ = jni::make_global(
CallInvokerHolder::newObjectCxxArgs(runtimeSchedulerCallInvoker));
} else {
jsCallInvokerHolder_ = jni::make_global(
CallInvokerHolder::newObjectCxxArgs(instance_->getJSCallInvoker()));
}
auto runtimeScheduler = getRuntimeScheduler();
auto runtimeSchedulerCallInvoker =
std::make_shared<RuntimeSchedulerCallInvoker>(
runtimeScheduler->cthis()->get());
jsCallInvokerHolder_ = jni::make_global(
CallInvokerHolder::newObjectCxxArgs(runtimeSchedulerCallInvoker));
}
return jsCallInvokerHolder_;
}
Expand Down Expand Up @@ -440,7 +426,7 @@ CatalystInstanceImpl::getRuntimeExecutor() {

jni::alias_ref<JRuntimeScheduler::javaobject>
CatalystInstanceImpl::getRuntimeScheduler() {
if (enableRuntimeScheduler_ && !runtimeScheduler_) {
if (!runtimeScheduler_) {
auto runtimeExecutor = instance_->getRuntimeExecutor();
auto runtimeScheduler = std::make_shared<RuntimeScheduler>(runtimeExecutor);

Expand Down
12 changes: 2 additions & 10 deletions ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ class CatalystInstanceImpl : public jni::HybridClass<CatalystInstanceImpl> {
static constexpr auto kJavaDescriptor =
"Lcom/facebook/react/bridge/CatalystInstanceImpl;";

static jni::local_ref<jhybriddata> initHybrid(
jni::alias_ref<jclass>,
bool enableRuntimeScheduler,
bool enableRuntimeSchedulerInTurboModule);
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jclass>);

static void registerNatives();

Expand All @@ -51,9 +48,7 @@ class CatalystInstanceImpl : public jni::HybridClass<CatalystInstanceImpl> {
private:
friend HybridBase;

CatalystInstanceImpl(
bool enableRuntimeScheduler,
bool enableRuntimeSchedulerInTurboModule);
CatalystInstanceImpl();

void initializeBridge(
jni::alias_ref<ReactCallback::javaobject> callback,
Expand Down Expand Up @@ -120,9 +115,6 @@ class CatalystInstanceImpl : public jni::HybridClass<CatalystInstanceImpl> {
jni::global_ref<CallInvokerHolder::javaobject> nativeCallInvokerHolder_;
jni::global_ref<JRuntimeExecutor::javaobject> runtimeExecutor_;
jni::global_ref<JRuntimeScheduler::javaobject> runtimeScheduler_;

bool const enableRuntimeScheduler_;
bool const enableRuntimeSchedulerInTurboModule_;
};

} // namespace react
Expand Down

0 comments on commit 2b57b74

Please sign in to comment.