NEW 258572
performance.timeOrigin drifts slowly during the lifetime of a page
https://bugs.webkit.org/show_bug.cgi?id=258572
Summary performance.timeOrigin drifts slowly during the lifetime of a page
Nic Jansma
Reported 2023-06-27 07:41:00 PDT
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
Attachments
Noam Rosenthal
Comment 1 2023-06-29 02:40:26 PDT
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.
Radar WebKit Bug Importer
Comment 2 2023-07-04 07:41:14 PDT
Note You need to log in before you can comment on or make changes to this bug.