hermes-profile-transformer icon indicating copy to clipboard operation
hermes-profile-transformer copied to clipboard

error Cannot read properties of undefined (reading 'pid')

Open ThaJay opened this issue 2 years ago • 3 comments

First I followed https://reactnative.dev/docs/hermes/ then https://reactnative.dev/docs/profile-hermes

Recording a Hermes sampling profile seems to succeed (hermes-profile-transformer is in my node-modules at version 0.0.6) Then the command to convert and transfer the Hermes tracing profile fails as follows:

$ npx react-native profile-hermes ./dev
info Downloading a Hermes Sampling Profiler from your Android device...
info No filename is provided, pulling latest file
info File to be pulled: sampling-profiler-trace552874595700445033.cpuprofile
error Cannot read properties of undefined (reading 'pid').
TypeError: Cannot read properties of undefined (reading 'pid')
    at Function.collectProfileEvents (/Users/dev/app/node_modules/hermes-profile-transformer/dist/hermes-profile-transformer.cjs.development.js:315:28)
    at /Users/dev/app/node_modules/hermes-profile-transformer/dist/hermes-profile-transformer.cjs.development.js:517:43
    at async downloadProfile (/Users/dev/app/node_modules/@react-native-community/cli-hermes/build/profileHermes/downloadProfile.js:160:24)
    at async Object.profileHermes [as func] (/Users/dev/app/node_modules/@react-native-community/cli-hermes/build/profileHermes/index.js:28:5)
    at async Command.handleAction (/Users/dev/app/node_modules/@react-native-community/cli/build/index.js:192:9)
info Run CLI with --verbose flag for more details.

$ react-native info
info Fetching system and libraries information...
(node:25683) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
System:
    OS: macOS 12.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 857.19 MB / 16.00 GB
    Shell: 5.1.16 - /usr/local/bin/bash
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 8.5.0 - /usr/local/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK: Not Found // but it is present, API level 30
  IDEs:
    Android Studio: 2021.1 AI-211.7628.21.2111.8309675
    Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.14.1 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.67.2 => 0.67.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

ThaJay avatar Jun 16 '22 13:06 ThaJay

Hi, can you adb pull the cpuprofile and send it on here? I think your profile is missing a pid field.

saphal1998 avatar Jun 22 '22 12:06 saphal1998

I'm getting the same error, this is the cpuprofile pulled:

$ cat /var/folders/g2/cp3zswzj13xg8gq_7zp4cc4r0000gn/T/sampling-profiler-trace2636271394659753988.cpuprofile
{"traceEvents":[{"name":"process_name","ph":"M","cat":"__metadata","pid":12534,"ts":"4948145047","tid":"-1","args":{"name":"hermes"}},{"name":"thread_name","ph":"M","cat":"__metadata","pid":12534,"ts":"4948145047","tid":"12667","args":{"name":"pool-13-thread-"}},{"name":"pool-13-thread-","cat":"pool-13-thread-","ph":"X","dur":0,"pid":12534,"ts":"4948145047","tid":"12667","args":{}}],"samples":[],"stackFrames":{}}%
$ yarn react-native info
info Fetching system and libraries information...
System:
    OS: macOS 12.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 93.06 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.6.0 - /opt/homebrew/bin/node
    Yarn: 1.18.0 - /opt/homebrew/bin/yarn
    npm: 8.11.0 - /opt/homebrew/bin/npm
    Watchman: 2022.07.04.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.2 AI-212.5712.43.2112.8609683
    Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.15 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: Not Found
    react-native: 0.66.3 => 0.66.3
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

zeevl avatar Sep 17 '22 19:09 zeevl

Unfortunately this still happens years later

evelant avatar Sep 16 '24 20:09 evelant