You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why is there no performance advantage when testing the synchronous bridge of TurboModule in version 0.82.1 compared to the old NativeModules synchronous bridge? Is the testing methodology flawed?
The testing methodology involves clicking a button on the same device after a cold start, then invoking a for-loop to call the TurboModule and NativeModules bridges 1000 times each, measuring total execution time. The results show that TurboModule's performance is inconsistent (fluctuating within a similar range), with some cases even exhibiting degradation.
Our current hypothesis is that the React Native core library's requireModule does not invoke the __turboModuleProxy branch, instead routing all calls to the NativeModules branch. Is this behavior expected?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Why is there no performance advantage when testing the synchronous bridge of TurboModule in version 0.82.1 compared to the old NativeModules synchronous bridge? Is the testing methodology flawed?
The testing methodology involves clicking a button on the same device after a cold start, then invoking a for-loop to call the TurboModule and NativeModules bridges 1000 times each, measuring total execution time. The results show that TurboModule's performance is inconsistent (fluctuating within a similar range), with some cases even exhibiting degradation.
Our current hypothesis is that the React Native core library's requireModule does not invoke the __turboModuleProxy branch, instead routing all calls to the NativeModules branch. Is this behavior expected?

The code is as follows:
`/**
*/
import { NewAppScreen } from '@react-native/new-app-screen';
import { StatusBar, Button, StyleSheet, useColorScheme, View, NativeModules } from 'react-native';
import {
SafeAreaProvider,
useSafeAreaInsets,
} from 'react-native-safe-area-context';
import UnifiedBridge from './js/NativeUnifiedBridge';
const { OldBridge } = NativeModules;
function App() {
const isDarkMode = useColorScheme() === 'dark';
return (
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
<Button
onPress={() => {
// TODO 新桥调用测试
const startTime1 = performance.now();
var ret1 = UnifiedBridge.invokeNativeMethodSync(JSON.stringify({ key: Math.random().toString() }));
const endTime1 = performance.now();
console.log('invokeNativeMethodSync took ' + (endTime1 - startTime1) + ' ms ret:' + ret1);
}}
title="新桥调用"
color="#272727ff"
accessibilityLabel="Learn more about this purple button"
/>
);
}
function AppContent() {
const safeAreaInsets = useSafeAreaInsets();
// callNativeMethod();
return (
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
export default App;`
Beta Was this translation helpful? Give feedback.
All reactions