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

Error: Cannot read properties of undefined (reading 'name')

Open gentlee opened this issue 1 year ago • 0 comments

Reproduce steps:

  1. Enable sampling profiler on android device (Xiaomi Redmi Go)
  2. Disable it
  3. Download .cpuprofile
  4. Transform with transform script (without source maps)
  5. Try upload to chrome dev performance tab
  6. Got the error

Input: sampling-profiler-trace3882871943179202698.cpuprofile Output (unzip): chrome-supported.json.zip

Transform script:

/**
 * Used to transform hermes profiler outputs to supported by chrome dev tools.
 * https://github.com/react-native-community/hermes-profile-transformer
 */

const transformer = require('hermes-profile-transformer').default
const { writeFileSync } = require('fs')

const hermesCpuProfilePath = 'sampling-profiler-trace3882871943179202698.cpuprofile'

transformer(
  // profile path is required
  hermesCpuProfilePath
  // source maps are optional
  // sourceMap,
  // sourceMapBundleFileName
)
  .then((events) => {
    // write converted trace to a file
    return writeFileSync('./chrome-supported.json', JSON.stringify(events, null, 2), 'utf-8')
  })
  .catch((err) => {
    console.log(err)
  })

gentlee avatar Nov 22 '23 14:11 gentlee