Unable to see components in the trace
I have created some components in the react native sample app. But I am not being able to find them in profiler. reproducer -> https://github.com/demon-sword/sampleAppProfiling
This is the App component
startProfiling()
function App(): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
return (
<SafeAreaView style={backgroundStyle}>
<Component1 />
<Button title={'StopProfiling'} onPress={() => {
stopProfiling(true)
}}/>
</SafeAreaView>
);
}
This is the profile that is generated by the produced by the package
sampling-profiler-trace-1.cpuprofile.txt
The things I have tried -:
- Class components
- Functional Components
- Exporting components by default
- Adding displayNames to components
- Tried with Arrow function components as well
Can you please help
The profiler is a sampling profiler, so if your function is executed within a short period of time (like <1ms) there is high chances that this function will not be included in a final report.
Can you add a code that blocks an execution of js thread for certain period of time (let's say 200ms) to your component (inside render) and check again?
const start = new Date().getTime();
while (new Date().getTime() - start < 200) {}
Plus i think this example is also missing symbolication.