1 of 14

timeOrigin

WHAT IS THE MEANING OF TIME!?!?!

Nic Jansma @nicj

2 of 14

In the beginning...

There was:

> performance.timing.navigationStart

1686231991133

(... and there still is! but it's now deprecated)

3 of 14

And he had a friend, the DOMHighResTimeStamp

> performance.now()

202103

> performance.getEntriesByType("resource").map( r => r.startTime)[0]

814.1999998092651

4 of 14

With their powers combined, you can CALCULATE TIME!

I don't always do math, but when I do, I do it against the Unix Epoch:

> performance.now() + performance.timing.navigationStart

202103 + 1686231991133 = 1686232320745.4

> new Date(performance.now() + performance.timing.navigationStart)

Thu Jun 08 2023 09:52:00 GMT-0400 (Eastern Daylight Time) // nowish

5 of 14

Then we said...

Let there be .timeOrigin!

> performance.timeOrigin

1686231991133.2

And then we saw the light! (of microseconds(optional))

(and then we deprecated performance.timing.*)

6 of 14

So let's switch!

Use the modern interface first:

> var timeOrigin =� performance.timeOrigin || � (performance.timing || {}).navigationStart ||� new Date().getTime(); // via Request Metrics

> new Date(performance.now() + myTimeOrigin)

// nowish???

7 of 14

Challenge #1: Confusion

What does it mean when they're different?

Firefox 114:

Safari 16.4:

Chrome:

8 of 14

Challenge #1: Confusion

What does it mean when they're different?

9 of 14

Challenge #1: Confusion

Can they be different?

The one case maybe from the spec is on browser launch of the first nav:

The time origin is the time value from which time is measured: ... the time when the browsing context is first created if there is no previous document; ...

https://www.w3.org/TR/hr-time-2/#sec-time-origin

10 of 14

Challenge #2: Browser Bugs: Chrome

Process start time?

https://bugs.chromium.org/p/chromium/issues/detail?id=1365808

This issue is a really serious problem for us, if I’m understanding correctly that performance.timeOrigin is no longer a reliable measurement for the time origin of a web page being opened.

We use performance.timeOrigin for client performance measurements that we collect and persist in a database for analysis. This issue means that starting with 105 we now potentially have a pile of corrupted/dirty data mixed in with the rest, with no way to tell the good from the bad across literally thousands of customers.

This is a catastrophe for this use case. Can a fix for this be prioritized more highly? Every day that passes, we’re collecting more and more bad data mixed in with the good.

FIXED

11 of 14

Challenge #2: Browser Bugs: Firefox

Process start time?

Examples of 10ms, 400ms, 75,000,000ms (20 hr) difference between .timeOrigin and .navigationStart

12 of 14

Challenge #2: Browser Bugs: Safari

Safari Drift

.timeOrigin is changing over time

13 of 14

Challenge #3: vs. .startTime?

vs. NavigationTimingEntry.startTime

If .timeOrigin != .navigationStart, shouldn't the "navigation" entry's .startTime not be 0?

14 of 14

Summary

  • Should .timeOrigin and .timing.navigationStart be the same?
    • ... yes?
  • Browser bugs
    • Some fixed, some in progress, some need to be filed
  • Result = RUM can't reliably use .timeOrigin at all
    • But using the "deprecated" .timing.navigationStart interface