New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 594941 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Mar 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

mouse events having wrong timestamp

Reported by katams...@gmail.com, Mar 15 2016

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0

Steps to reproduce the problem:
1. Attach mouse listeners:
document.addEventListener('mousemove', function(e){
	console.log(e.timeStamp);
}, false);
document.addEventListener('mousedown', function(e){
	console.log(e.timeStamp);
}, false);

2. load page
3. move with mouse over screen and watch timestamps growing instantly

What is the expected behavior?
timestamp should be the moment the event happens

What went wrong?
looks like timestamp is set to reload page event and grows from this point.

Did this work before? Yes earlier versions

Chrome version: 49.0.2623.87 m  Channel: n/a
OS Version: 10.0
Flash Version: Shockwave Flash 21.0 r0
 
Components: -Blink Blink>Input
Labels: Hotlist-Input-Dev
This seems to be working fine. 

> looks like timestamp is set to reload page event and grows from this point.

I'm not sure what you mean by "reload page event" but the times will increase as time passes. The timestamps are in milliseconds.
Cc: ashej...@chromium.org
Labels: Needs-Feedback
Owner: majidvp@chromium.org
Status: Assigned (was: Unconfirmed)
This is anticipated because of change 
https://developers.google.com/web/updates/2016/01/high-res-timestamps?hl=en

But sending to majidvp@ for resolution in case there is a bug in here.

Comment 4 by katams...@gmail.com, Mar 16 2016

OK, thanks for the update on that. But the description of the linked article points to a false conclusion:

"The timeStamp property of the Event interface indicates the time at which a given event took place."

So from version 49 on the value doesn't point to the time at which the event took place, instead it points relatively to the navigation point of time. As described further down in the article.
I think that sentence is accurate. It is definitely the "time" of the event but not the "epoch time" (or calendar time) which you are assuming. Time values do not imply epoch origin by default. This is consistent with the wording used in high-resolution timestamp spec [1].

The next few sentences in that article should make clear the time origin that is being used both before and after the change. If that is not clear we should try to address it in the article.

[1] https://w3c.github.io/hr-time/#time-origin 
Cc: rbyers@chromium.org
Labels: -Needs-Feedback
Status: WontFix (was: Assigned)
BTW, I am curious if you could share how this change impacted you in practice (e.g., what functionality broke?) and if you were able to apply any workarounds either from that article or otherwise.

Closing the bug for now as this working as intended. Feel free to re-open if there is any new information that warrants it.

Comment 7 by katams...@gmail.com, Mar 16 2016

I was comparing the timeStamp with the last on touchmove event (web app) for scrolling a list and calculating the speed of movement. But I considered the timeStamp as a epoch value not as a relative value.

I now built a bridge ("if(chrome){...}") to handle this in another way. As per W3C, as I understand, chrome will handle the event timeStamp in its very own way: 

https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-interface
Thanks for sharing.

I advice against using an "if(chrome)" and instead detecting the time origin and branch your code based on that. Not only because older chrome versions still behave as before but also Firefox is planning to make the switch in the future [1] and the DOM spec is changing as well to reflect this.

A simple way to detect this is to record Date.now() at your application load time and compare the event time stamp with that. See below for a simple example of this that should works for touch events but a more sophisticated approach that works for general events may be found at [2].

// ensure this runs before event handlers are added 
var dateNowAtLoad = Date.now();

ontouchmove = (e) => {
  if (e.timeStamp > dateNowAtLoad) {
    // epoch timestamp -> old path
  } else {
    // high-res timestamp -> new path
  }
}

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1026804
[2] https://github.com/majido/high-resolution-timestamp-polyfill/blob/master/translate-timeStamp.js
 

Comment 9 by katams...@gmail.com, Mar 16 2016

Ok, I wasn't honest with you. I have a check like your suggestion since already a year when apple released a bug in timeStamp :)

I just do the check now for every browser. So every browser can change now, I am prepared. Thx for your time, I like the support / and chrome.

Sign in to add a comment