Android key events event.timeStamp is always equal to zero
Reported by
tsniatow...@opera.com,
Mar 15 2017
|
|||
Issue descriptionChrome Version: master as of Mar 14, 2017 OS: Android N What steps will reproduce the problem? (1) Load https://developer.mozilla.org/en-US/docs/Web/API/Event/timeStamp (2) Focus iframe with test code (3) Press a keyboard key What is the expected result? A sane number appears and increases with each keypress. What happens instead? 0 is printed on each keypress Event timestamps should be monotonic, and ideally in milliseconds since page load. This is the case with mouse events like "click", but keyboard events appear to have been broken for a long time, and got progressively more broken over time culminating in the current "always 0" behavior.
,
Mar 15 2017
The issue is more apparent if you happen to have a machine with uptime of about 25 days aka over 2^31 microseconds.
,
Mar 15 2017
Thanks for the investigation. It looks like this is the only place in the code where we made the jlong -> long mistake.
,
Mar 15 2017
I made the changes that caused Event.timeStamp to always return 0, which is one of the side-effects that i ignored when i was pushing the change. The intent of my change was to reuse The monotonicTimeToDOMHighResTimeStamp(...) implementation for PerformanceResourceTiming and PerformanceNavigationTiming. And we figured, it doesn't make much sense to let monotonicTimeToDOMHighResTimeStamp(...) return any negative values. That's why two explicit checks were added to make sure that no negative values get returned. Apparently, monotonicTimeToDOMHighResTimeStamp(...) is also being used for other purposes than returning performance-related timing values. I am happy to take on the bug to revert our changes if needed.
,
Mar 15 2017
Don't worry, you don't need to revert. tsniatowski@ has a fix for the root cause at https://codereview.chromium.org/2755453004/
,
Mar 15 2017
,
Mar 15 2017
Sounds good!
,
Mar 16 2017
I guess event.timeStamp is technically a performance-related timing value... but that doesn't stop, say, a site that I won't name, from tying business logic to having the event timestamps changing over time. I can't guarantee there isn't some other code path that'll end up getting negative values through the conversion function, but the linked CL should definitely help. Anyway, the clamping only made the underlying problem need more immediate fixing, I didn't need to touch it to fix this bug. And, aelias@, thanks for checking the other long/jlongs, I haven't had the time to look around too much.
,
Mar 16 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/6bda2b55ca3d254ca021560906d0703e8b0df21e commit 6bda2b55ca3d254ca021560906d0703e8b0df21e Author: tsniatowski <tsniatowski@opera.com> Date: Thu Mar 16 08:17:50 2017 Fix android key event timestamps Pass a Java long to C++ as a jlong type, not a C++ long which can have a different size to avoid broken / negative event timestamp values. ImeAdapter's Java side uses "long" in SendKeyEvent, so the C++ side must use a jlong or int64_t, and not a C++ long. Otherwise things don't work well when system uptime is over 2^31ms (~25 days). Additionally, do not do an extra divide-by-1000 when the used helper function will do the milliseconds to seconds conversion already, so the timestamps are correctly measured in milliseconds. The resulting keyboard event timestamps end up nicely sane and positive, and no longer clamped to 0 in PerformanceBase.cpp. BUG= 701726 R=aelias@chromium.org Review-Url: https://codereview.chromium.org/2755453004 Cr-Commit-Position: refs/heads/master@{#457369} [modify] https://crrev.com/6bda2b55ca3d254ca021560906d0703e8b0df21e/content/browser/renderer_host/ime_adapter_android.cc [modify] https://crrev.com/6bda2b55ca3d254ca021560906d0703e8b0df21e/content/browser/renderer_host/ime_adapter_android.h
,
Mar 16 2017
,
Mar 16 2017
> that doesn't stop, say, a site that I won't name, from tying business logic to having the event timestamps changing over time. If this is a public-facing website, it would be useful to note here which site was broken by this problem. Then we can dupe any other bug that may be filed about this site into this one. (Fine not to describe it if it's an internal customer.)
,
Mar 16 2017
yeah, not a public-facing website |
|||
►
Sign in to add a comment |
|||
Comment 1 by tsniatow...@opera.com
, Mar 15 2017