Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ public abstract class com/facebook/react/ReactPackageTurboModuleManagerDelegate
public fun getEagerInitModuleNames ()Ljava/util/List;
public fun getLegacyModule (Ljava/lang/String;)Lcom/facebook/react/bridge/NativeModule;
public fun getModule (Ljava/lang/String;)Lcom/facebook/react/turbomodule/core/interfaces/TurboModule;
public fun unstable_enableSyncVoidMethods ()Z
public fun unstable_isLegacyModuleRegistered (Ljava/lang/String;)Z
public fun unstable_isModuleRegistered (Ljava/lang/String;)Z
public fun unstable_shouldEnableLegacyModuleInterop ()Z
Expand Down Expand Up @@ -1970,7 +1969,6 @@ public class com/facebook/react/config/ReactFeatureFlags {
public static field enableFabricRenderer Z
public static field enableViewRecycling Z
public static field traceTurboModulePromiseRejections Z
public static field unstable_enableTurboModuleSyncVoidMethods Z
public static field unstable_useFabricInterop Z
public static field unstable_useTurboModuleInterop Z
public static field useTurboModules Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ interface ModuleProvider {
ReactFeatureFlags.enableBridgelessArchitecture
&& ReactFeatureFlags.unstable_useTurboModuleInterop;

private final boolean mEnableTurboModuleSyncVoidMethods =
ReactFeatureFlags.unstable_enableTurboModuleSyncVoidMethods;

// Lazy Props
private List<ReactPackage> mPackages;
private ReactApplicationContext mReactContext;
Expand Down Expand Up @@ -143,10 +140,6 @@ public boolean unstable_shouldEnableLegacyModuleInterop() {
return mShouldEnableLegacyModuleInterop;
}

public boolean unstable_enableSyncVoidMethods() {
return mEnableTurboModuleSyncVoidMethods;
}

@Nullable
@Override
public TurboModule getModule(String moduleName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ public class ReactFeatureFlags {
/** In Bridgeless mode, should legacy NativeModules use the TurboModule system? */
public static volatile boolean unstable_useTurboModuleInterop = false;

/**
* By default, native module methods that return void run asynchronously. This flag will make
* execution of void methods in TurboModules stay on the JS thread.
*/
public static volatile boolean unstable_enableTurboModuleSyncVoidMethods = false;

/**
* Should this application use the new (Fabric) Renderer? If yes, all rendering in this app will
* use Fabric instead of the legacy renderer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public TurboModuleManager(
(CallInvokerHolderImpl) jsCallInvokerHolder,
(NativeMethodCallInvokerHolderImpl) nativeMethodCallInvokerHolder,
delegate);
installJSIBindings(shouldEnableLegacyModuleInterop(), enableSyncVoidMethods());
installJSIBindings(shouldEnableLegacyModuleInterop());

mEagerInitModuleNames =
delegate == null ? Collections.emptyList() : delegate.getEagerInitModuleNames();
Expand Down Expand Up @@ -113,10 +113,6 @@ private boolean shouldEnableLegacyModuleInterop() {
return mDelegate != null && mDelegate.unstable_shouldEnableLegacyModuleInterop();
}

private boolean enableSyncVoidMethods() {
return mDelegate != null && mDelegate.unstable_enableSyncVoidMethods();
}

@Override
@NonNull
public List<String> getEagerInitModuleNames() {
Expand Down Expand Up @@ -389,8 +385,7 @@ private native HybridData initHybrid(
NativeMethodCallInvokerHolderImpl nativeMethodCallInvoker,
TurboModuleManagerDelegate tmmDelegate);

private native void installJSIBindings(
boolean shouldCreateLegacyModules, boolean enableSyncVoidMethods);
private native void installJSIBindings(boolean shouldCreateLegacyModules);

@Override
public void invalidate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ public boolean unstable_shouldEnableLegacyModuleInterop() {
return false;
}

/* Can TurboModule methods that return void execute on the JS thread? */
public boolean unstable_enableSyncVoidMethods() {
return false;
}

// TODO(T171231381): Consider removing this method: could we just use the static initializer
// of derived classes instead?
protected synchronized void maybeLoadOtherSoLibraries() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,31 +128,27 @@ void TurboModuleManager::registerNatives() {

TurboModuleProviderFunctionType TurboModuleManager::createTurboModuleProvider(
jni::alias_ref<jhybridobject> javaPart,
jsi::Runtime* runtime,
bool enableSyncVoidMethods) {
return
[runtime, weakJavaPart = jni::make_weak(javaPart), enableSyncVoidMethods](
const std::string& name) -> std::shared_ptr<TurboModule> {
auto javaPart = weakJavaPart.lockLocal();
if (!javaPart) {
return nullptr;
}

auto cxxPart = javaPart->cthis();
if (cxxPart == nullptr) {
return nullptr;
}

return cxxPart->getTurboModule(
javaPart, name, *runtime, enableSyncVoidMethods);
};
jsi::Runtime* runtime) {
return [runtime, weakJavaPart = jni::make_weak(javaPart)](
const std::string& name) -> std::shared_ptr<TurboModule> {
auto javaPart = weakJavaPart.lockLocal();
if (!javaPart) {
return nullptr;
}

auto cxxPart = javaPart->cthis();
if (cxxPart == nullptr) {
return nullptr;
}

return cxxPart->getTurboModule(javaPart, name, *runtime);
};
}

std::shared_ptr<TurboModule> TurboModuleManager::getTurboModule(
jni::alias_ref<jhybridobject> javaPart,
const std::string& name,
jsi::Runtime& runtime,
bool enableSyncVoidMethods) {
jsi::Runtime& runtime) {
const char* moduleName = name.c_str();
TurboModulePerfLogger::moduleJSRequireBeginningStart(moduleName);

Expand Down Expand Up @@ -192,8 +188,7 @@ std::shared_ptr<TurboModule> TurboModuleManager::getTurboModule(
.moduleName = name,
.instance = moduleInstance,
.jsInvoker = jsCallInvoker_,
.nativeMethodCallInvoker = nativeMethodCallInvoker_,
.shouldVoidMethodsExecuteSync = enableSyncVoidMethods};
.nativeMethodCallInvoker = nativeMethodCallInvoker_};

auto turboModule = cxxDelegate->getTurboModule(name, params);
if (moduleInstance->isInstanceOf(
Expand Down Expand Up @@ -294,8 +289,7 @@ std::shared_ptr<TurboModule> TurboModuleManager::getLegacyModule(
.moduleName = name,
.instance = moduleInstance,
.jsInvoker = jsCallInvoker_,
.nativeMethodCallInvoker = nativeMethodCallInvoker_,
.shouldVoidMethodsExecuteSync = false};
.nativeMethodCallInvoker = nativeMethodCallInvoker_};

static auto getMethodDescriptorsFromModule =
javaPart->getClass()
Expand Down Expand Up @@ -326,21 +320,18 @@ std::shared_ptr<TurboModule> TurboModuleManager::getLegacyModule(

void TurboModuleManager::installJSIBindings(
jni::alias_ref<jhybridobject> javaPart,
bool shouldCreateLegacyModules,
bool enableSyncVoidMethods) {
bool shouldCreateLegacyModules) {
auto cxxPart = javaPart->cthis();
if (cxxPart == nullptr || !cxxPart->jsCallInvoker_) {
return; // Runtime doesn't exist when attached to Chrome debugger.
}

cxxPart->runtimeExecutor_([cxxPart,
javaPart = jni::make_global(javaPart),
shouldCreateLegacyModules,
enableSyncVoidMethods](jsi::Runtime& runtime) {
shouldCreateLegacyModules](jsi::Runtime& runtime) {
TurboModuleBinding::install(
runtime,
cxxPart->createTurboModuleProvider(
javaPart, &runtime, enableSyncVoidMethods),
cxxPart->createTurboModuleProvider(javaPart, &runtime),
shouldCreateLegacyModules
? cxxPart->createLegacyModuleProvider(javaPart)
: nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,15 @@ class TurboModuleManager : public jni::HybridClass<TurboModuleManager> {

static void installJSIBindings(
jni::alias_ref<jhybridobject> javaPart,
bool shouldCreateLegacyModules,
bool enableSyncVoidMethods);
bool shouldCreateLegacyModules);

static TurboModuleProviderFunctionType createTurboModuleProvider(
jni::alias_ref<jhybridobject> javaPart,
jsi::Runtime* runtime,
bool enableSyncVoidMethods);
jsi::Runtime* runtime);
std::shared_ptr<TurboModule> getTurboModule(
jni::alias_ref<jhybridobject> javaPart,
const std::string& name,
jsi::Runtime& runtime,
bool enableSyncVoidMethods);
jsi::Runtime& runtime);

static TurboModuleProviderFunctionType createLegacyModuleProvider(
jni::alias_ref<jhybridobject> javaPart);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ namespace TMPL = TurboModulePerfLogger;
JavaTurboModule::JavaTurboModule(const InitParams& params)
: TurboModule(params.moduleName, params.jsInvoker),
instance_(jni::make_global(params.instance)),
nativeMethodCallInvoker_(params.nativeMethodCallInvoker),
shouldVoidMethodsExecuteSync_(params.shouldVoidMethodsExecuteSync) {}
nativeMethodCallInvoker_(params.nativeMethodCallInvoker) {}

JavaTurboModule::~JavaTurboModule() {
/**
Expand Down Expand Up @@ -531,9 +530,7 @@ jsi::Value JavaTurboModule::invokeJavaMethod(
const char* methodName = methodNameStr.c_str();
const char* moduleName = name_.c_str();

bool isMethodSync =
(valueKind == VoidKind && shouldVoidMethodsExecuteSync_) ||
!(valueKind == VoidKind || valueKind == PromiseKind);
bool isMethodSync = !(valueKind == VoidKind || valueKind == PromiseKind);

if (isMethodSync) {
TMPL::syncMethodCallStart(moduleName, methodName);
Expand Down Expand Up @@ -813,15 +810,6 @@ jsi::Value JavaTurboModule::invokeJavaMethod(
return returnValue;
}
case VoidKind: {
if (shouldVoidMethodsExecuteSync_) {
env->CallVoidMethodA(instance, methodID, jargs.data());
checkJNIErrorForMethodCall();

TMPL::syncMethodCallExecutionEnd(moduleName, methodName);
TMPL::syncMethodCallEnd(moduleName, methodName);
return jsi::Value::undefined();
}

TMPL::asyncMethodCallArgConversionEnd(moduleName, methodName);
TMPL::asyncMethodCallDispatch(moduleName, methodName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class JSI_EXPORT JavaTurboModule : public TurboModule {
jni::alias_ref<jobject> instance;
std::shared_ptr<CallInvoker> jsInvoker;
std::shared_ptr<NativeMethodCallInvoker> nativeMethodCallInvoker;
bool shouldVoidMethodsExecuteSync;
};

JavaTurboModule(const InitParams& params);
Expand All @@ -57,7 +56,6 @@ class JSI_EXPORT JavaTurboModule : public TurboModule {
// instance_ can be of type JTurboModule, or JNativeModule
jni::global_ref<jobject> instance_;
std::shared_ptr<NativeMethodCallInvoker> nativeMethodCallInvoker_;
bool shouldVoidMethodsExecuteSync_;
};

} // namespace facebook::react