Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get JS function names in HermesSamplingProfiler #1414

Open
demon-sword opened this issue Jun 2, 2024 · 3 comments
Open

Unable to get JS function names in HermesSamplingProfiler #1414

demon-sword opened this issue Jun 2, 2024 · 3 comments
Labels
need more info Awating additional info before proceeding

Comments

@demon-sword
Copy link

I have been trying to use HermesSamplingProfiler for the release builds in order to get function execution flamechart. But for some reason , some of the JS function names are missing in the trace.

Repro - https://github.com/demon-sword/sampleAppProfiling

This is a sample App which is using react-native-release-profiler(https://github.com/margelo/react-native-release-profiler) which internally uses HermesSamplingProfiler to generate the trace.

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>
  );
}
Screenshot 2024-05-31 at 3 07 05 PM [sampling-profiler-trace-1.cpuprofile.txt](https://github.com/user-attachments/files/15525281/sampling-profiler-trace-1.cpuprofile.txt) As you can see in the image that there is only App component is available in the trace. Nothing About Component1 in the trace and there are some empty blocks in the trace as well. The things I have tried -:
  1. Class components
  2. Functional Components
  3. Exporting components by default
  4. Adding displayNames to components
  5. Tried with Arrow function components as well
  6. Disabling minification of js bundle.
  7. Tried on nightly as well

React Native version: 0.74.1
OS: Android

Steps To Reproduce

  1. Create a release build with the given repo.
  2. Run the build and click on stopprofiling button on the screen.
  3. A trace will be saved in the downloads folder.
  4. open the trace in speedscope.com
@demon-sword demon-sword added the bug Something isn't working label Jun 2, 2024
@tmikov
Copy link
Contributor

tmikov commented Jun 6, 2024

We aren't ignoring this issue, we are just slammed with other things. We will get to it, I promise...

@neildhar
Copy link
Contributor

Hey @demon-sword, thanks for reporting this. It looks like JS functions are showing up in your trace. The blank frames likely represent unnamed JS functions.

It looks like the trace you uploaded has very little activity though. Of the 297 samples captured by the profiler, only 2 have anything actually running on the stack. There just isn't enough running for the profiler to pick it up. If you increase the amount of activity in the application, you should get a more complete trace.

@neildhar neildhar added need more info Awating additional info before proceeding and removed bug Something isn't working labels Jun 10, 2024
@demon-sword
Copy link
Author

Hey @neildhar, thanks for getting back to me.

As I mentioned in the code, there aren't any unnamed JS functions in my code. Therefore, ideally, there shouldn't be any blank frames. If React Native is invoking some unnamed functions internally, that's a different matter.

The trace I've shared was recorded from the app start to the mounting of the App Component. Thus, it should include details of all the components mounted within the App Component, such as Component1 in my case. You can view it here:https://github.com/demon-sword/sampleAppProfiling/blob/main/App.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more info Awating additional info before proceeding
Projects
None yet
Development

No branches or pull requests

3 participants