04-11-2024 02:36 PM - edited 04-11-2024 02:52 PM
While building out some RUM observability code, I noticed that the `performance.timeOrigin` could be significantly in the past for some users. I don't know why or how this happens but I am wondering if it has anything to do with the browser preloading the page, or some other interaction with cache like bfcache. I have seen this issue in Firefox, Chrome, and Edge which leads me to believe my understanding of `performance.timeOrigin` is not right.
The assumption that I am currently working from is that `performance.timeOrigin` is the precise moment the page began loading (which the definition for is up for debate) while `performance.now()` is the milliseconds since that time. It's the latter part of that assumption that I really seem to have a problem with.
The data:
{
// Everything below is data from in-browser
"Date.now": 1712869191634, // Browser time at time of execution
"global.timeOrigin": 1712866335518, // Value of `performance.timeOrigin`
"global.navigationStart": 1712869187273, // Value of `performance.timing.navigationStart`
"localTimeDiff": -2851493, // `global.timeOrigin - global.navigationStart`
"timeSincePageOrigin": 4361, // Value of `performance.now()`
"originTime": 1712866335518, // Value of `window.performance.timeOrigin`
"userAgentName": "Firefox",
"userAgentOS": "Mac",
"userAgentVersion": "124.0"
}
From the data, it appears the browser context was create ~47 minutes before navigation started. What am I misunderstanding here?
04-11-2024 03:15 PM - edited 04-11-2024 03:20 PM
Personal note of possibly relevant links:
https://developer.mozilla.org/en-US/docs/Web/API/Performance/timeOrigin
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceTiming/navigationStart
https://bugzilla.mozilla.org/show_bug.cgi?id=1710762
https://issues.chromium.org/issues?q=timeOrigin
https://github.com/getsentry/sentry-javascript/issues/2590
https://github.com/newrelic/newrelic-browser-agent/pull/966