-
-
Notifications
You must be signed in to change notification settings - Fork 47
Description
Hello,
I'm attempting a very simple use of react-native-performance
:
React.useEffect(() => {
new PerformanceObserver(() => {
const marks = performance.getEntriesByType('react-native-mark')
console.log(JSON.stringify(marks, null, 2))
}).observe({ type: 'react-native-mark', buffered: true })
I put the code above in my App.tsx
.
My log is shown correctly when I run a iOS simulator:
LOG [
{
"name": "nativeLaunchStart",
"entryType": "react-native-mark",
"startTime": 576733058,
"duration": 0,
"detail": null
},
{
"name": "nativeLaunchEnd",
"entryType": "react-native-mark",
"startTime": 576733563,
"duration": 0,
"detail": null
},
...
But when I run the same exact code on my Android simulator my log is empty. Unless I crash my app:
React.useEffect(() => {
new PerformanceObserver(() => {
const marks = performance.getEntriesByType('react-native-mark')
console.log(JSON.stringify(marks, null, 2))
}).observe({ type: 'react-native-mark', buffered: true })
setTimeout(() => {
throw new Error('Test')
}, 3000)
}, [])
As seen above, if I purposefully crash my app after 3 seconds, the logs suddenly appear on Android, just like for iOS.
I don't understand what is wrong, could it be a problem of setup of Android? I followed the documentation and it seems like there is nothing more than installing the lib with yarn.
I'm using the following versions:
"react-native": "0.73.11",
"react-native-performance": "^5.1.2",
Btw, I'm using an open-source project so all the configuration files are accessible:
https://github.com/pass-culture/pass-culture-app-native
To me it seems like something is leaving the measures "hanging" on Android and when I crash the app, that process is interrupted making the observer retrieve the values. I could be wrong, but I can provide more information if needed.
Thank you in advance.