Skip to content

High-resolution event timestamp breaks eventToMetaData #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
majido opened this issue Feb 3, 2016 · 2 comments
Closed

High-resolution event timestamp breaks eventToMetaData #130

majido opened this issue Feb 3, 2016 · 2 comments

Comments

@majido
Copy link

majido commented Feb 3, 2016

Chrome is switching the Event.timeStamp from DOMTimeStamp to a DOMHighResTimeStamp in 49th release (Firefox is going to make the switch in near future too). After this change the value is no longer comparable to Date.now() in chrome which is likely to impact your eventToMetaData function logic for calculating millisecondsAgo.

Note that the current logic is actually broken in Firefox, as it does not use an epoch timeStmap for most input events.

I am the developer who is making the change in Chrome, and I came across your library as I was doing bulk static analysis. This blog post has additional details about the change but I am happy to answer any questions you have as well.

@ConradIrwin
Copy link

@majido just want to thank you for making that change! progress++

Fixing the library should be relatively easy, if it's close to new Date().getTime() we can use it as a TimeStamp, if not, it's a DOMHighResTimeStamp https://github.com/RByers/rbyers.github.io/blob/master/scroll-latency.js#L23-L26. That also explains why this feature didn't work reliable on Firefox :)

@majido
Copy link
Author

majido commented Feb 3, 2016

Thanks! It is definitely a step in the right direction. :)

@RByers approach works fine as long as you know that the event in question occurred fairly recently.
The approach I have been using is to take a Date.now() timestamp at page load time and treat any value larger than that as DOMTimeStamp with unix epoch timestamp. You can take a look at how that approach can work here: https://github.com/majido/high-resolution-timestamp-polyfill/blob/master/translate-timeStamp.js

That logic also handles the Firefox case too. It is fairly new code and has not been extensively tested. So feel free to send pull request if you noticed something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants