hermes-profile-transformer
hermes-profile-transformer copied to clipboard
Error: Cannot read properties of undefined (reading 'name')
Reproduce steps:
- Enable sampling profiler on android device (Xiaomi Redmi Go)
- Disable it
- Download .cpuprofile
- Transform with transform script (without source maps)
- Try upload to chrome dev performance tab
- 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)
})