Accessing performance.timeOrigin repeatedly during the lifetime of a page shows that it drifts slowly. For example, when I first load a page and query performance.timeOrigin I get: > [new Date, performance.timeOrigin] < [Tue Jun 27 2023 07:34:57 GMT-0700 (Pacific Daylight Time), 1687876483498.0002] Then, a few minutes later when I'm querying the same API, I get: > [new Date, performance.timeOrigin] < [Tue Jun 27 2023 07:35:37 GMT-0700 (Pacific Daylight Time), 1687876483497] In this case, it went "backwards" by 1.0002 ms. Then again a minute later: > [new Date, performance.timeOrigin] < [Tue Jun 27 2023 07:36:56 GMT-0700 (Pacific Daylight Time), 1687876483494] In this case, it went "backwards" by 3ms. In other instances, I've seen the time drift "forward" slowly over time[1]. timeOrigin should not be changing during the lifetime of the page. [1] https://docs.google.com/presentation/d/1RW_fLZwUevn7IBXE3hFvKMnaEBs83Dxp3_yLflEfAXk/edit#slide=id.g22706244ab9_0_111
I double-checked the spec, and indeed it should be stable throughout the lifetime of the document. In https://w3c.github.io/hr-time/#dfn-estimated-monotonic-time-of-the-unix-epoch, the "estimated monotonic time of the Unix epoch" is initialized once, while in https://github.com/WebKit/WebKit/blob/main/Source/WebCore/page/Performance.cpp#L86 it's effectively computed every time timeOrigin() is called.
<rdar://problem/111742735>