<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>258572</bug_id>
          
          <creation_ts>2023-06-27 07:41:00 -0700</creation_ts>
          <short_desc>performance.timeOrigin drifts slowly during the lifetime of a page</short_desc>
          <delta_ts>2023-07-04 07:41:14 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Page Loading</component>
          <version>Safari 16</version>
          <rep_platform>Mac (Apple Silicon)</rep_platform>
          <op_sys>macOS 12</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nic Jansma">nic</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>achristensen</cc>
    
    <cc>beidson</cc>
    
    <cc>noam</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1963806</commentid>
    <comment_count>0</comment_count>
    <who name="Nic Jansma">nic</who>
    <bug_when>2023-06-27 07:41:00 -0700</bug_when>
    <thetext>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:

&gt; [new Date, performance.timeOrigin]
&lt; [Tue Jun 27 2023 07:34:57 GMT-0700 (Pacific Daylight Time), 1687876483498.0002]

Then, a few minutes later when I&apos;m querying the same API, I get:

&gt; [new Date, performance.timeOrigin]
&lt; [Tue Jun 27 2023 07:35:37 GMT-0700 (Pacific Daylight Time), 1687876483497]

In this case, it went &quot;backwards&quot; by 1.0002 ms.

Then again a minute later:

&gt; [new Date, performance.timeOrigin]
&lt; [Tue Jun 27 2023 07:36:56 GMT-0700 (Pacific Daylight Time), 1687876483494]

In this case, it went &quot;backwards&quot; by 3ms.

In other instances, I&apos;ve seen the time drift &quot;forward&quot; 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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1964213</commentid>
    <comment_count>1</comment_count>
    <who name="Noam Rosenthal">noam</who>
    <bug_when>2023-06-29 02:40:26 -0700</bug_when>
    <thetext>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 &quot;estimated monotonic time of the Unix epoch&quot; is initialized once, while in https://github.com/WebKit/WebKit/blob/main/Source/WebCore/page/Performance.cpp#L86 it&apos;s effectively computed every time timeOrigin() is called.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1964984</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-07-04 07:41:14 -0700</bug_when>
    <thetext>&lt;rdar://problem/111742735&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>