[android] All react-native-mark are relative to system.uptime
bestander opened this issue · comments
I see discrepancy in behavior between iOS and Android.
On Android all react-native-mark marks are relative to the OS uptime and all manual performance.mark() calls are in unix time.
This makes it difficult to align react native startup markers with all the rest because system uptime is not exposed to RN runtime.
[
{
"duration": 0,
"entryType": "react-native-mark",
"name": "nativeLaunchStart",
"startTime": 46830987
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "nativeLaunchEnd",
"startTime": 46831916
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "processCoreReactPackageStart",
"startTime": 46900808
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "downloadStart",
"startTime": 46900096
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "preRunJsBundleStart",
"startTime": 46901261
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "preSetupReactContextStart",
"startTime": 46901261
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "createUiManagerModuleConstantsEnd",
"startTime": 46901427
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "bridgeSetupStart",
"startTime": 46900093
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "setupReactContextEnd",
"startTime": 46901437
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "contentAppeared",
"startTime": 46901773
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "vmInit",
"startTime": 46900805
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "createUiManagerModuleStart",
"startTime": 46901261
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "attachMeasuredRootViewsEnd",
"startTime": 46901437
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "reactContextThreadStart",
"startTime": 46900770
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "reactContextThreadEnd",
"startTime": 46900804
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "createViewManagersStart",
"startTime": 46901261
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "createCatalystInstanceStart",
"startTime": 46901025
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "createViewManagersEnd",
"startTime": 46901261
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "createReactContextStart",
"startTime": 46900806
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "preSetupReactContextEnd",
"startTime": 46901261
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "createUiManagerModuleEnd",
"startTime": 46901427
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "buildNativeModuleRegistryEnd",
"startTime": 46901025
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "buildNativeModuleRegistryStart",
"startTime": 46901025
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "createCatalystInstanceEnd",
"startTime": 46901260
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "setupReactContextStart",
"startTime": 46901261
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "attachMeasuredRootViewsStart",
"startTime": 46901261
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "createUiManagerModuleConstantsStart",
"startTime": 46901261
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "downloadEnd",
"startTime": 46900727
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "processCoreReactPackageEnd",
"startTime": 46900811
},
{
"detail": undefined,
"duration": 0,
"entryType": "mark",
"name": "Test",
"startTime": 1627518139392
}
]
On iOS marks are consistent and relative to performance.now():
[
{
"detail": undefined,
"duration": 0,
"entryType": "mark",
"name": "Test",
"startTime": 61274217.183125004
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "nativeLaunchStart",
"startTime": 61246463
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "nativeLaunchEnd",
"startTime": 61259702
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "downloadStart",
"startTime": 61260965
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "downloadEnd",
"startTime": 61273060
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "runJsBundleStart",
"startTime": 61273075
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "runJsBundleEnd",
"startTime": 61273772
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "bridgeSetupStart",
"startTime": 61260520
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "bridgeSetupEnd",
"startTime": 61273773
},
{
"duration": 0,
"entryType": "react-native-mark",
"name": "contentAppeared",
"startTime": 61274668
},
{
"detail": undefined,
"duration": 0,
"entryType": "metric",
"name": "bundleSize",
"startTime": 61274669.021291,
"value": 4426135
}
]
Seems like a similar issue with the built-in performance.now
implementation on Android: facebook/react-native#30069
The workaround there was to capture an origin point INITIAL_OFFSET
by calling performance.now()
as early as possible
Then to see time relative to app launch (well JS launch) you'd use const timeSinceLaunch = performance.now() - INITIAL_OFFSET
I think performance.timeOrigin
(in this library) captures that point so you could do const timeSinceLaunch = performance.now() - performance.timeOrigin
Similarly if you want to see the startTime
for entries relative to app launch you can use
performance.getEntries().forEach(entry => log(entry.startTime - performance.timeOrigin));
Maybe system uptime is used, as it won't be affected by the user changing the Date and time of the system?
React Native 0.68 is unifying timestamps across platforms and this PR does the same to this library which should solve this issue: #71