diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm index b9a0996bff3a0e..61b7430fb23afc 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm +++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm @@ -684,7 +684,7 @@ id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, s return true; } - return isSyncModule_ || !(returnType == VoidKind || returnType == PromiseKind); + return !(returnType == VoidKind || returnType == PromiseKind); } ObjCTurboModule::ObjCTurboModule(const InitParams ¶ms) @@ -707,7 +707,9 @@ id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, s const char *moduleName = name_.c_str(); const char *methodName = methodNameStr.c_str(); - if (isMethodSync(returnType)) { + bool isSyncInvocation = isSyncModule_ || isMethodSync(returnType); + + if (isSyncInvocation) { TurboModulePerfLogger::syncMethodCallStart(moduleName, methodName); } else { TurboModulePerfLogger::asyncMethodCallStart(moduleName, methodName); @@ -715,7 +717,7 @@ id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, s NSMutableArray *retainedObjectsForInvocation = [NSMutableArray arrayWithCapacity:count + 2]; NSInvocation *inv = createMethodInvocation( - runtime, isMethodSync(returnType), methodName, selector, args, count, retainedObjectsForInvocation); + runtime, isSyncInvocation, methodName, selector, args, count, retainedObjectsForInvocation); jsi::Value returnValue = jsi::Value::undefined(); @@ -730,24 +732,24 @@ id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, s [retainedObjectsForInvocation addObject:resolveCopy]; [retainedObjectsForInvocation addObject:rejectCopy]; // The return type becomes void in the ObjC side. - performMethodInvocation(runtime, isMethodSync(VoidKind), methodName, inv, retainedObjectsForInvocation); + performMethodInvocation(runtime, isSyncInvocation, methodName, inv, retainedObjectsForInvocation); }); } else { id result = - performMethodInvocation(runtime, isMethodSync(returnType), methodName, inv, retainedObjectsForInvocation); + performMethodInvocation(runtime, isSyncInvocation, methodName, inv, retainedObjectsForInvocation); - if (isMethodSync(returnType)) { + if (isSyncInvocation) { TurboModulePerfLogger::syncMethodCallReturnConversionStart(moduleName, methodName); } returnValue = convertReturnIdToJSIValue(runtime, methodName, returnType, result); - if (isMethodSync(returnType)) { + if (isSyncInvocation) { TurboModulePerfLogger::syncMethodCallReturnConversionEnd(moduleName, methodName); } } - if (isMethodSync(returnType)) { + if (isSyncInvocation) { TurboModulePerfLogger::syncMethodCallEnd(moduleName, methodName); } else { TurboModulePerfLogger::asyncMethodCallEnd(moduleName, methodName);