Bug 217099 - Timestamp clock drift when computing event delay
Summary: Timestamp clock drift when computing event delay
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari Technology Preview
Hardware: Mac macOS 10.14
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-09-29 12:39 PDT by Philip Walton
Modified: 2020-10-06 12:40 PDT (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Walton 2020-09-29 12:39:24 PDT
Steps to reproduce the issue:

1. Navigate to https://event-delay-tester.glitch.me
2. Click, tap, keypress on the page and notice the reported event delays
3. Wait for a few minutes...or an hour
4. Repeat step 2 and notice that event delays are now negative.
5. Close and re-open the browser and notice event delays are back to normal

The code on that page compares `performance.now()` to `event.timeStamp` in the event listeners, so it appears that (as the page stays open longer) there's some sort of clock drift happening that affects one of those two APIs but not the other.
Comment 1 Alexey Proskuryakov 2020-09-29 15:57:51 PDT
Without actually checking the specs, this sounds like expected behavior - performance.now would be monotonically increasing time unaffected by NTP adjustments, and timestamps would be actual device clock, comparable to Date.now.

Does this work differently in other browsers?
Comment 2 Philip Walton 2020-09-29 16:33:17 PDT
Both `performance.now()` and `event.timeStamp` return `DOMHighResTimeStamp`, so I'd expect both APIs to be consistently comparable throughout the lifespan on the browser app being open.

> Does this work differently in other browsers?

Yes, I'm not seeing any drift in Firefox or Chrome (also tested on Mac, within the same time window).
Comment 3 Alexey Proskuryakov 2020-09-29 17:38:58 PDT
I was going to agree with you, but then I saw this in the DOM living standard:

"In macOS the time of the occurrence for input actions is available via the timestamp property of NSEvent objects."

So I'll leave this to DOM lawyers to decide upon.
Comment 4 Radar WebKit Bug Importer 2020-10-06 12:40:32 PDT
<rdar://problem/70011970>