Skip to content
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

High resolution timing for events #23

Closed
annevk opened this issue Apr 17, 2015 · 70 comments · Fixed by #420
Closed

High resolution timing for events #23

annevk opened this issue Apr 17, 2015 · 70 comments · Fixed by #420

Comments

@annevk
Copy link
Member

annevk commented Apr 17, 2015

https://lists.w3.org/Archives/Public/public-web-perf/2014Jun/0013.html
https://bugzilla.mozilla.org/show_bug.cgi?id=1026804

@annevk
Copy link
Member Author

annevk commented Aug 3, 2015

@birtles, what is the timeline for this?

@birtles
Copy link

birtles commented Aug 5, 2015

I expect to finish converting our Linux UI event timestamps over on non-release channels this quarter. Still need to find someone to do the Mac work so we can switch this on for release channels.

@RByers
Copy link
Contributor

RByers commented Sep 22, 2015

We (@majido) are working on this in blink too. There are two completely different things coupled together here:

  1. Use logical event time instead of strict "event creation time".
  2. Use a monotonic/high-precision time (DOMHighRestTimestamp) instead of an epoch time.

It's 1 that's most important IMHO, giving us two key properties:

  • Ability to accurately compute pointer velocity
  • A basic way to measure input latency (very important for tracking improvements to some class of perf problems IMHO).
    But it's also potentially hardest to spec. Eg. does the spec currently require that events are delivered in increasing timestamp order? If we rely on OS/device timestamps then it's possible, for example, that a touchmove may be dispatched after a mousemove with a later timestamp.

WebKit has done 1 without 2 for a couple years now, but it's a kludge. Given the lack of use cases for an epoch-based event timestamp and the existing lack of interoperability here, I agree we should also try to change the semantics of timestamp.

@annevk
Copy link
Member Author

annevk commented Dec 10, 2015

This might not be web-compatible: https://bugzilla.mozilla.org/show_bug.cgi?id=1231619#c3. But perhaps browsers are willing to push it through anyway...

@RByers
Copy link
Contributor

RByers commented Jan 31, 2016

Yep, @majido says the compat impact seems manageable, so we're still pushing ahead with shipping in Chrome 49 (currently in beta, set to go stable in early March). If we have non-trivial compat issues we'll revert and revisit adding a new property instead.

@foolip
Copy link
Member

foolip commented Feb 2, 2016

Some fallout of the change: https://code.google.com/p/chromium/issues/detail?id=574514

@wycats
Copy link

wycats commented Feb 6, 2016

I find it quite surprising that this is considered an acceptable web-compatible change, for the reasons that @chancancode discussed on the Bugzilla thread.

The jQuery API docs and MDN both define event.timeStamp as "The difference in milliseconds between the time the browser created the event and January 1, 1970". Incorrect or not, the practical effect of this is that lots and lots of code exists in the wild that assumes that new Date() and event.timeStamp can be compared to produce a relative amount of milliseconds.

Of course, new Date() and the old event.timeStamp are not very reliable as they are not monotonic (I'm very familar with these problems as the author of the RFCs that added Duration and timestamp functionality to Rust)

That said, I am shocked that decoupling the meaning of event.timeStamp from new Date() is considered even remotely web compatible. Immediate fallout included a demo @chancancode and I happened to be working on for the Ember rendering engine, Angular animation code, and the MSE test suite reported by @foolip.

A more conservative solution to the problem would be to introduce a new attribute (event.time as a nice shorter name? event.performance.timeStamp for symmetry with window.performance.*?).

Given the kinds of things that have blocked shipping recently for web-compat reasons, and the number of affected properties, I just don't understand how we're full steam ahead here. (In the linked case, the problematic feature had already shipped in IE11 and Edge years earlier, which made the number of affected properties quite small.)

To quote @chancancode:

By the way, if you are thinking that code that compares against wall-clock time is fundamentally "incorrect", I totally agree with you, and I am personally looking forward to using this feature. However, correctness is irrelevant here because event timestamps have always been tied to wall-clock time, and there are no better way to do this today. The fact is it basically work "good enough" for the majority cases that people have been able to build useful things on top of it today, and we should be careful not to break them. (For example, popular libraries like underscore uses Date.now for debouncing/throttling – while "incorrect", it obviously works "good enough" to be useful in the wild.)

I would quote him in full, but I'd recommend just reading the linked Bugzilla thread.

@RByers
Copy link
Contributor

RByers commented Feb 6, 2016

"Lots and lots of sites" has not been our experience. But as with anything compat, data trumps anecdote here. @majido, can you share your analysis from httparchive data? Anyone else have more examples of specific sites impacted? If we find a pattern that, say, we find used on >0.01% of the top sites in httparchive then we should definitely reconsider.

FWIW I argued ages ago for a new Event systemTime property, and we went around-and-around for years and couldn't get it spec'd anywhere due to constant debate about whether it was better to add a new property (if so which spec) or fix the old one. Firefox never implemented the UNIX-epoch version, so felt changing the timebase was already largely web compatible and understandably didn't want to regress to using wall-times in a property that was already (rightly) monotonic for them.

So attempting to ship a breaking change in Chrome was our compromise. So far it's hit Chrome beta with millions of users and very little fallout, so we have no reason to pull the plug yet. We're still willing for new data to change our mind, but the time for arguing-absent-hard-data (after more than 3 years of such arguing blocking solving the use cases here) is done IMHO.

@wycats
Copy link

wycats commented Feb 6, 2016

So attempting to ship a breaking change in Chrome was our compromise. So far it's hit Chrome beta with millions of users and very little fallout, so we have no reason to pull the plug yet.

The problem with timing bugs is that they don't necessarily manifest as hard errors, by definition. Given how flaky some websites can be already, it may take some time before people report the bug, even to the original author, and before that bug gets reported upstream.

In this case, we rapidly discovered a (rather subtle) bug in a very popular animation library (Angular) that is easy to reproduce. How is that not sufficient?

(the fact that Angular has addressed the issue in 1.5 doesn't really do much -- some existing content will upgrade, but plenty won't)

@wycats
Copy link

wycats commented Feb 6, 2016

If we find a pattern that, say, we find used on >0.01% of the top sites in httparchive then we should definitely reconsider.

Is there a way we can test uses of:

  • e.timeStamp - anyDate
  • anyDate - e.timeStamp
  • var d = e.timeStamp, later: anyDate - d or d - anyDate

I'd be very very surprised if those patterns did not impact a non-trivial number of the top sites.

@RByers
Copy link
Contributor

RByers commented Feb 6, 2016

The problem with timing bugs is that they don't necessarily manifest as hard errors, by definition. Given how flaky some websites can be already, it may take some time before people report the bug, even to the original author, and before that bug gets reported upstream.

Yeah I agree that's cause for extra concern here. Also there may be non-visual cases where the breakage is hidden from us, eg. where the client sends the timestamp to the server for some analytics.

In this case, we rapidly discovered a (rather subtle) bug in a very popular animation library (Angular) that is easy to reproduce. How is that not sufficient?

We believe the impact in practice is small (due to low usage of the particular affected feature from our httparchive digging and as a result of being cosmetic). @majido can provide the concrete data from his analysis.

Is there a way we can test uses of: ...

Yes, the first two are, I believe, the analysis @majido has done on httparchive data for the top 470k websites. I'll let him provide details. Such code has always been broken on Firefox (except for the specific event that Angular was using, due to a bug in Firefox where it's timestamp was always 0), so it does make sense that developers haven't been relying on this.

I should add that unfortunately I'm out on vacation without internet for the next 1.5 weeks. Please continue discussing the tradeoff with Majid - he owns this feature on blink. If you like you're welcome to follow-up on the Intent to ship thread, it's possible other blink API owners with disagree with our judgement here and request the change be un-shipped.

@RByers
Copy link
Contributor

RByers commented Feb 6, 2016

BTW, some devrel outreach around this here

@wycats
Copy link

wycats commented Feb 6, 2016

Here's another example of a kind of pattern that could be affected:

https://github.com/cubiq/iscroll/blob/v4/src/iscroll-lite.js#L207

that.startTime = e.timeStamp || Date.now();

This is from v4 of Cubiq iscroll, which was both a pretty popular solution for a little while, and used in a lot of websites that are no longer maintained.

I'm not sure if this is actually a problem (I can't tell if the associated method is ever invoked synthetically, perhaps for initialization), but neither can simple static analysis.

Related: "it's often broken in Firefox" doesn't affect mobile websites much, which heavily use e.timeStamp together with touch events for various time-sensitive operations. All that'll happen is that some mobile website that hasn't been updated since 2010 will stop scrolling (or the scrolling will get janky, or the momentum will be horribly off), and who's going to report that, and to whom?

@annevk
Copy link
Member Author

annevk commented Feb 8, 2016

I think I'm convinced we should do this via a new property instead given the reported subtle breakage.

However, #23 (comment) mentions that timeStamp is also not quite implemented in the same way across browsers so I guess whatever we do that'll need to change a little bit.

@majido, @birtles, what do you think?

@majido
Copy link
Member

majido commented Feb 8, 2016

Hi,

I think @RByers summarized our thinking and the background pretty well in #23 (comment)

It is difficult (impossible?) to actually measure the impact before hand in this case and our hope has been that once we hit beta we receive better feedback which we are getting.

However, I also did an analysis using very recent (Jan 15, 2016 dataset) httparchive data which shows the impact is likely to be < 0.02%. I looked for the following patterns in top 477k top sites (both mobile and desktop) and tried to categorize and understand if they get broken and I have assumed breakage if the usage was not obvious.

  • e.timeStamp - value
  • value - e.timeStamp

Clearly this is not the complete picture but gives a sense that the usage of this pattern is quite limited.

In cases where I have seen the issue in a library and have outreached (eg, 1 and 2) the fix has been trivial and has address an error or a workaround in the logic for Firefox.

@domenic
Copy link
Member

domenic commented Feb 8, 2016

Given how timeStamp cannot really be used compatibly across browsers anyway, and the fact that this has hit Chrome 49 without needing to be reverted, I think we should stay the course and fix timeStamp instead of inventing a new property and also incurring all the risk involved in fixing timeStamp to be cross-browser compatible.

@majido
Copy link
Member

majido commented Feb 8, 2016

At the moment I tend to agree with @domenic. Based on current data and our beta experience until now the impact appears to be limited in scope (although subtle) and within our expected range. Not sure if we should change our strategy yet.

To be fair, most of the code that tries to compare Event.timeStamp with Date.now() is already broken in subtle and not so subtle ways:

  • Not dealing with system wall time skews
  • Improperly handling firefox edge cases (e.g., In Firefox value may be: zero, a unix epoch but in microseconds, or millisecond value in system startup time).
  • Invalid comparison between monotonic and non-monotonic clocks In Safari which can lead to subtle bugs. (In safari, the event timestamp is monotonic but with unix epoch timebase )

@chancancode
Copy link

I want to reiterate a few things (excuse me for being brief as I am on mobile):

shows the impact is likely to be < 0.02%

That appears to be higher than @RByers's proposed threshold of 0.01% (which is 1 in 10,000 sites):

If we find a pattern that, say, we find used on >0.01% of the top sites in httparchive then we should definitely reconsider.

Also, the analysis:

  • e.timeStamp - value
  • value - e.timeStamp

That does not cover any of the reported cases, including Angular's use case.

...and I have assumed breakage if the usage was not obvious.

None of the reported cases hard errors and only break in ways that cannot be easily detected.

...the fix has been trivial...

Unfortunately, fixing a library going forward doesn't affect existing deployments. It by definition is irrelevant to web compat.

So, I don't agree that we have data to prove that this doesn't matter, even if it has shipped in Chrome beta.

@wycats
Copy link

wycats commented Feb 8, 2016

It's worth reiterating that the breakage in Angular (which was in code in the main angular.js), would not have been detected by the already-done static analysis.

It also would not have detected the bug that @chancancode and I found in our demo code (we stored e.timestamp in an object).

It also seems that this change breaks at least some part of YouTube, which is still not fixed as of 3 days ago, per comment 24 on chrome bug 574514:

Yes, I am the right owner to fix the test. This test is to ensure that browsers don't break YouTube. I'm going to wait until YouTube fixes their code before I fix the test. As of right now, the event.timeStamp epoch is still a requirement for YouTube.

Even thought it didn't detect these cases, the number of cases detected by simplistic static analysis still exceeds the speculative threshold of 0.01.

While 0.01% sounds like a small number, it means that it affects 1 / 10,000 sites. The static analysis also breaks out "bugsnag". Bugsnag is an error reporting tool that the static analysis suggests accounts for another 0.01% on its own. Again, this is just a case that happened to be detected using the static analysis.

Timing-related bugs are subtle and hard to track down, and this particular change will affect old sites which aren't even maintained anymore. Given that a number of high-profile breakages have already been reported, and that it doesn't manifest as a hard error, I'm having a hard time understanding why the experiment has not conclusively failed.

@domenic
Copy link
Member

domenic commented Feb 8, 2016

Part of the reason is because those usages already failed in Firefox (in many cases) and Safari (in fewer cases, but more subtly). They're clearly survivable.

@wycats
Copy link

wycats commented Feb 8, 2016

Given how timeStamp cannot really be used compatibly across browsers anyway

I also wanted to add that this is simply not correct. While timeStamp cannot be used compatibly across browsers in a completely generic way (say, a library operating on all events), there is a large subset of cases that has historically been compatible, and which web content relies on.

The fact that some events do not fit in this subset does not mean we can break the events that do.

I would like someone to tell me what rules I should apply in the future when dealing with web compat issues, because frankly, this thread has made me question whether I understand the rulebook we're supposed to be following.

@wycats
Copy link

wycats commented Feb 8, 2016

Part of the reason is because those usages already failed in Firefox (in many cases) and Safari (in fewer cases, but more subtly). They're clearly survivable.

"clearly survivable" is overstating the case. The fact that some cases of e.timeStamp didn't work in Firefox didn't stop Angular animations or YouTube from working reliably on Firefox.

@stefanpenner
Copy link

the fact that this has hit Chrome 49 without needing to be reverted

This seems somewhat self-prepatuating, especially since issues have been (and continue to be raised). So by ignoring issues, yes chrome has not needed to revert...

Part of the reason is because those usages already failed in Firefox (in many cases) and Safari (in fewer cases, but more subtly). They're clearly survivable.

A path of success was possible, but that changed with Chrome 49.


It seems transitioning to high-precision timer since posix epoch may address the concerns being raised, with what seems like little cost? Maybe I'm missing something...

@majido
Copy link
Member

majido commented Feb 8, 2016

It seems transitioning to high-precision timer since posix epoch may address the concerns being raised, with what seems like little cost? Maybe I'm missing something...

In that case the timeStamp value will look similar to Date.now() but only on surface. The actual value is coming from a different monotonic clock which unlike Date.now() is not impacted by NTP time skew. This means that the developers are more likely to compare it with Date.now() which is going to break in subtle ways in random machine which makes the bug hard to detect. To quote dbaron from here

Shipping a feature where a developer getting it wrong means their page is intermittently broken on a small percentage of machines seems pretty bad. Seems like people are likely to get that wrong forever. It seems better to actually go through a more-breaking change once.

If we decide not to change Event.timeStamp then a better solution is to actually use a different attribute.

@majido
Copy link
Member

majido commented Feb 8, 2016

Also, the analysis:

e.timeStamp - value
value - e.timeStamp
That does not cover any of the reported cases, including Angular's use case.
No it does not.

...and I have assumed breakage if the usage was not obvious.
None of the reported cases hard errors and only break in ways that cannot be easily detected.

Sorry, if I was not clear. In this case I meant that if I was not fairly sure about "o.timeStamp - value" usage I assumed it gets broken (i.e., o.timeStamp is an event value and values is a date). To be honest based on the codes I check during the process most of the time this pattern end up being safe, e.g., either timeStamp is coming from Date.now() or value is another timeStamp but I erred on the side of over estimating the breakage in this case.

While 0.01% sounds like a small number, it means that it affects 1 / 10,000 sites. The static analysis also breaks out "bugsnag". Bugsnag is an error reporting tool that the static analysis suggests accounts for another 0.01% on its own. Again, this is just a case that happened to be detected using the static analysis.

In fact, I think 0.01% of the issue being attributed to bugsnag is a promising sign (not to discount other issues). Their usage is essentially what I would categorize under "clearly survivable" category. They usage pattern is to compute a millisecondsAgo for the last event which is reported as part of the metadata for when an error is reported. There is no user-facing impact, and their code was reporting invalid values for Firefox that apparently no one noticed. This is simple to fix and also has also a backend solution. This is the best possible breakage and they seem to be happy about the change.

It's worth reiterating that the breakage in Angular (which was in code in the main angular.js), would have been detected by the already-done static analysis.

I think you meant would NOT have been detected.

It also would not have detected the bug that @chancancode and I found in our demo code (we stored e.timestamp in an object).

Correct.

So the simplistic analysis over counts in some cases and under counts in others. Which is why I don't like to rely too much on it. Just to get a sense of things in combination with other evidence.

@bzbarsky
Copy link

One point of record: @dbaron's quote above wrt to a more-breaking change was a response to a suggestion that we define event.timeStamp in terms of performance.now() + navigationStart, more or less, so it looks comparable to Date.now() values. But isn't really, as clocks drift during the lifetime of the page. He was saying he would prefer just having event.timeStamp not be comparable to Date.now() at all to that setup.

@RByers
Copy link
Contributor

RByers commented Apr 28, 2016

Ok let's take the rhetoric down a notch, we're all trying to do the best thing for the web platform.

There was general agreement that (in order to resolve the multi-year debate about whether a new API is necessary or not) Chrome should attempt to ship this change. Once we started down that path and were getting concrete data, our judgement (vocal opposition notwithstanding) was that the compat issues we were seeing were minor and the short-term cost caused was well below the long-term cost to the platform of introducing a confusing and largely redundant API. So we did not see a need to reverse course. But I recognize this is entirely a judgement call where opinions of reasonable engineers will differ.

If Mozilla and Apple now feel that, despite not having concrete examples of real sites that are broken today in Chrome, there still needs to be a new API for this, then by all means please spec such an API, ship it in at least one of your engines, and we'll be happy to follow suit. We really do want to see the problem of reliably measuring input event latency solved once and for all in an interoperable way.

@annevk
Copy link
Member Author

annevk commented Apr 28, 2016

It seems that from #23 (comment) the current requirement in DOM for timeStamp is not onerous and can be implemented across browsers.

It's not clear if we want to store two different times for each event, forever (different in both origin and resolution). (Though Apple seems okay with this given @rniwa's comment.)

It's also not clear what the compatibility impact is of changing timeStamp, exactly, though with Chrome shipping the change it cannot be huge, I think. Though as suggested earlier we might know more in a couple of months.

It seems unlikely other vendors will ship something fast, given #23 (comment) and #23 (comment), so maybe the best approach here is to just wait it out a bit and see what actually happens.

@RByers
Copy link
Contributor

RByers commented Apr 28, 2016

It seems unlikely other vendors will ship something fast, given #23 (comment) and #23 (comment), maybe the best approach here is to just wait it out a bit and see what actually happens.

Actually @rniwa didn't say anything about the priority they'd give to landing a new API in WebKit here. @rniwa thoughts?

Note that with passive event listeners now shipping, we're starting to actively encourage the measurement of scroll latency using this API. But all our examples will show a pattern that works for both the WebKit and blink implementations (the only two implementations today exposing the original driver time), so it'll probably still be possible for us to switch back to the WebKit behavior in the future without causing too much disruption (it'll just introduce the NTP skew problem in scenarios that were previously more stable in Chrome, but we don't know how bad that tends to be in practice).

So if collecting more data on the impact in Chrome over a few months would be valuable to this debate, then that's fine with me. But if no amount of such additional data would change other implementor's minds then there's no benefit to waiting.

@wycats
Copy link

wycats commented Apr 28, 2016

Ok let's take the rhetoric down a notch, we're all trying to do the best thing for the web platform.

I apologize for the rhetoric, and I agree fully that everyone here is trying to do what they believe is best for the platform and the browsers they work on.

So if collecting more data on the impact in Chrome over a few months would be valuable to this debate, then that's fine with me.

I think more data would indeed be useful, if we measure the right things.

Here are some things that (dynamic) telemetry might be helpful if unearthing, if you're willing to run it:

  • for each event:
    • comparisons of the value produced by e.timeStamp with the value produced by Date.now().
    • whether the timestamp used in such those comparisons came from e.timeStamp || Date.now(). For events where Firefox produced ms-since-unix-epoch or 0, this would have previously been guaranteed to produce a date, but now it does not.
    • runtime behavior equivalent to e.timeStamp || Date.now() (there are many ways to do this coercion, so a textual analysis is not enough).
    • usage of date.setTime(timestamp) or date.setTime(coercedTimestamp)

I'd be happy to discuss the exact telemetry that would be most helpful here, if you find this line of reasoning useful.

I'd also add that finding "hits" with this kind of telemetry does not prove that a site is broken, but it will give us a corpus of sites to evaluate manually.

Personally, I'm especially concerned about the vast number of "iOS lookalike" sites that were hand-crafted early in the days of iOS, because those sites were forced to reimplement scrolling, implement high-level touch events, implement animations and more, without the benefit of window.performance.now() even existing at all to give them a clue that they should avoid comparing e.timeStamp with Date.now().

Also, because those sites are largely "webkit only" in practice, they may well not have noticed the Firefox breakage at all, but these sites are on the Internet and most browsers have been attempting to support them.

tabatkins added a commit to tabatkins/dom that referenced this issue Apr 28, 2016
* Add more legacy event types for createEvent()

Approximately as requested at
https://bugzilla.mozilla.org/show_bug.cgi?id=1251198#c7. This is the
list of events supported in createEvent() by at least two of Firefox,
Chrome, and IE 11. The one exception is I omitted MutationEvent,
which all three support, because apparently spec-land has decided to
deny its existence in the hope that it will go away.

Bikeshed does not know about all of the added interface names,
hopefully that will sort itself out over time.

* Meta: improve pull request instructions for DOM

See whatwg/fetch#276 for context.

* Enable an event listener to be invoked just once

* Editorial: web compatibility typically remains relevant

Fixes whatwg#210.

* Shadow: define attachShadow() for custom elements

* Meta: make it easier to reference participate in a tree

PR: whatwg#216

* Define node document for new Text nodes

Fixes whatwg#224 and part of whatwg#212. Also fix part of whatwg#209 by stating these
algorithms can rethrow exceptions.

* Use a single concept for attribute changes

This setup is still a little sketchy I think, but not more so than the
insertion and removing steps.

* SVGEvent is only Gecko, Blink also has SVGEvents

As pointed out by zcorpan in whatwg#227.

* Set createDocument()'s content type based on namespace

Fixes whatwg#217.

PR: whatwg#218

* Make document.createEvent("touchevent") sometimes throw

Browsers typically disable touch events on non-touch devices, and there exists web content that detects this difference using document.createEvent().

Fixes whatwg#227.

* Shadow: define slotchange event

Shadow: define slotchange event

Fixes WICG/webcomponents#288.

This defines the slotchange event in response to remove/insert operations, changes to a slot’s name attribute, and changes to an element’s slot attribute.

This also introduces the assigned nodes concept for slots, and assigned slot concept for slotables.

Slotables now also have a name, rather than a “get name”.

The slotchange event dispatches just after mutation observers have their callbacks invoked. The slotchange event is not yet marked scoped as scoped events are not yet defined in the DOM Standard.

Note: although the original issue did not mention it, this also suppresses signaling when slots are removed from a tree. Not just when they are inserted.

* Editorial: update custom element cross-spec references

* Editorial: fix a few cross-linking missteps

* Editorial: make "is" and "prefix" optional in "create an element"

* Use "create an element" in createHTMLDocument

Takes care of part of whatwg#212.

* Editorial: align exception language with IDL

* Editorial: introduce more shadow-including terms for CSS

Fixes whatwg#225.

* Editorial: distributed -> flattened

* Meta: export more terms

Fixes whatwg#233.

* Editorial: add "shadow host" and "assigned" as terms

This makes a couple of non-null checks read better and enshrines a term
we had already been using.

* Editorial: flip non-null/otherwise conditions

PR: whatwg#234

* Shadow: <slot> is now defined in HTML

* Remove passive as event listener key

This changes makes passive no longer contribute to the uniqueness of
an event listener. It therefore also no longer needs to be supported
as part of removeEventListener().

Fixes WICG/EventListenerOptions#27.

PR: whatwg#236

* Meta: point out event's timeStamp is likely to change

See whatwg#23 for details.

* Add [CEReactions] annotations to mutating methods

Part of WICG/webcomponents#186, and furthering whatwg/html@27aa7bc.

Linking [CEREactions] will happen once speced/bikeshed#677 is fixed.

* Editorial: check stop propagation flag at start of invoke

* Editorial: deduplicate Veli Şenol

* Editorial: define defaults for EventListenerOptions

Although this is also done in prose, this nonetheless simplifies the
prose a bit and makes it clearer to those skimming the standard what is
going on (although skimming is not recommended).

Fixes whatwg#239.

* Meta: link to Japanese translation

See
triple-underscore/triple-underscore.github.io#1
for more details.
@dmethvin
Copy link

Just some data, event.timeStamp has been a PITA to jQuery for a long time since people expected us to fix it. It was broken in Firefox until 2014 and broken in Opera until 2012. We also received a report in 2012 that it was broken on Android 2.3 Dolphin. So anyone depending on reliable cross-browser results has been getting wrong answers until the last 3 or 4 years.

jQuery used to try patching this problem by filling in a Date.now() value for the timestamp if it was zero but removed that code in jQuery 1.7 (January 2011). I hope that encouraged people to stop using the value altogether, but you can still find various GitHub code and StackOverflow answers that assume the timestamp is compatible with Date.now().

@wycats
Copy link

wycats commented Apr 29, 2016

I had a good chat with @majido off-thread and we came up with some good telemetry that we agree would identify the impact of this change. I'm looking forward to the results!

@majido
Copy link
Member

majido commented Apr 29, 2016

It was a good chat indeed. :)

I am trying to see if I can gather more data using telemetry to better help make progress on the debate about the potential impact. This should help address some cases where our earlier static analysis of httparchive would have missed. I can only do this mainly thanks to @RByers recent efforts to enable cluster telemetry for Blink that allows such measurement for a set of top sites (e.g, top 10K).

Following @wycats suggestions I think we should measure the following cases:

  1. anyDate - timestamp or timestamp - anyDate
  2. new Date(timestamp)
  3. date.setTime(timestamp)

Where timestamp is a value that came from Event.timeStamp **

As pointed out earlier, this will over count because there is no guarantee that any of the operations above will actually lead to breakage but we can followup with a manual check on this smaller subset. I am discussing with our V8 experts to see if this is actually possible without a huge amount of work. I will update once I have an answer.

In any case, before spending too much effort on this I like to have some agreement that this is an acceptable experiments and an acceptable threshold (e.g., 0.02% of pages?) for seeing this type of usage leading to breakage.

Also particularly interested on what @rniwa think of the effectiveness of this measurements given his strong concerns on web-compat.

** I have not yet figured exactly how to tag timestamp and Date values as I believe they get converted into a numbers before being operated on. Perhaps I will use a special value (may impact program flow) or specific fractions (A lot less intrusive)

@wycats
Copy link

wycats commented Apr 29, 2016

In any case, before spending too much effort on this I like to have some agreement that this is an acceptable experiments and an acceptable threshold (e.g., 0.02% of pages?) for seeing this type of usage leading to breakage.

Generally speaking, I have concerns about treating any specific percentage of pages as evidence that breakage is ok. Because the web is so huge, "real" applications are a very small percentage. Maybe we could categorize breakage by things like presence of certain globals (Ember, Backbone, React), usage of other "tracer" features like history.pushState that would indicate that a website is more of an "application" than pure content?

If you're interested, I would love to help beef up Blink's usage analysis in this way ("application" is one useful category, but there are probably others, like "mobile site", etc.). It would make me feel a lot more confident that the identified features aren't heavily used in some pocket of the web.

@wycats
Copy link

wycats commented Apr 29, 2016

But I would also like to add that I think we can come up with a measurement that I could agree ahead of time would be enough (just not "total usage over the entire web").

@majido
Copy link
Member

majido commented Apr 29, 2016

But I would also like to add that I think we can come up with a measurement that I could agree ahead of time would be enough (just not "total usage over the entire web").

If I use cluster telemetry, the corpus will be pretty well defined (e.g. top 10K sites) rather than the entire web and I can better control for mobile vs desktop. Though it also means I can only test a pre-defined set of interactions but has the benefit of being able to get the URL of the page.

If I end up being able to get some type of safe measurement in Canary then it will be website used by Chrome Canary users. This is more like the entire web but page URL will not be available.

@RByers
Copy link
Contributor

RByers commented Apr 29, 2016

If you're interested, I would love to help beef up Blink's usage analysis in this way ("application" is one useful category, but there are probably others, like "mobile site", etc.). It would make me feel a lot more confident that the identified features aren't heavily used in some pocket of the web.

Yeah this is a problem the blink API owners (especially @foolip and I) have spent some time worrying about, but don't yet have any super-promising practical ideas around. We should think about it further and we'd love your help! We're ramping up our investments in our compat tooling, deprecation process, interop efforts, etc. I filed this chromium bug to track.

@majido
Copy link
Member

majido commented Apr 29, 2016

@dmethvin Thanks for the jQuery background. Current Event.timeStamp is PITA indeed. Hopefully we get it fixed one way or another soon.

Even today despite my experience using Event.timeStamp I got surprised seeing negative values (up to -300ms) for Date.now() - event.timeStamp for input events in Safari on Mac OS (demo page) /cc @rniwa. It is a small issue (most probably due to an NTP skew) compared to others but can lead to subtle head scratching bugs.

@RByers
Copy link
Contributor

RByers commented Sep 23, 2016

There was some discussion of this at TPAC:

  • @smaug---- said he wants to see this change land in Gecko as well (really would rather not have a new property, leaving the old confusing one indefinitely)
  • @n8schloss said having these high-res timestamps in Chrome has been very valuable to Facebook in their scroll performance investigations
  • A couple Edge perf folks said they would look into changing Edge for this (but aren't able to comment on this issue since it's in the WHATWG)
  • @rniwa indicated that if Gecko and/or Edge shipped this change alright, then perhaps WebKit may be able to as well but that @smfr was the one to talk to.

@SebastianZ
Copy link

FYI, bug 1026804 got fixed two days ago.

Sebastian

@cpeterso
Copy link

cpeterso commented Feb 26, 2017

After almost three years of testing with Firefox Nightly and Dev Edition users, Mozilla plans to ship high-resolution Event.timeStamp in Firefox 54 (2017-06-13). See @birtles' Intent to Ship announcement.

@annevk
Copy link
Member Author

annevk commented Feb 27, 2017

Okay, so with Chrome and Firefox shipping, these things still need to be done:

  • Bugs filed against Edge and WebKit.
  • Make sure there are sufficient web-platform-tests.
  • Prepare a pull request for the DOM Standard.

I'm happy to help folks if they want to take on one or more of these tasks.

@majido
Copy link
Member

majido commented Feb 28, 2017

  • Bugs: A Webkit bug is already filed. We just need to file one against Edge.
  • We wrote a some tests when we landed Blink implementation. They are written in web-platform-test style and I am pretty sure I can upstream at least two without any change.
  • Happy to send a pull-request against the spec if no one else does it in the meantime.

@annevk
Copy link
Member Author

annevk commented Jul 12, 2017

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jul 12, 2017
This is in anticipation of DOM spec patch landing [1].
Upstreaming two tests:
 - verify constructed events get a high-resolution time from perfomance.now()
 - verify the minimum resolution is larger that 5µs.

[1] whatwg/dom#23
[2] whatwg/dom#420

BUG=538600

Review-Url: https://codereview.chromium.org/2744553007
Cr-Commit-Position: refs/heads/master@{#485966}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jul 12, 2017
This is in anticipation of DOM spec patch landing [1].
Upstreaming two tests:
 - verify constructed events get a high-resolution time from perfomance.now()
 - verify the minimum resolution is larger that 5µs.

[1] whatwg/dom#23
[2] whatwg/dom#420

BUG=538600

Review-Url: https://codereview.chromium.org/2744553007
Cr-Commit-Position: refs/heads/master@{#485966}
scheib pushed a commit to scheib/chromium that referenced this issue Jul 12, 2017
This is in anticipation of DOM spec patch landing [1].
Upstreaming two tests:
 - verify constructed events get a high-resolution time from perfomance.now()
 - verify the minimum resolution is larger that 5µs.

[1] whatwg/dom#23
[2] whatwg/dom#420

BUG=538600

Review-Url: https://codereview.chromium.org/2744553007
Cr-Commit-Position: refs/heads/master@{#485966}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.