Commit e5c1b831 authored by Sarthak Shah's avatar Sarthak Shah Committed by Commit Bot

Add a histogram for pointer/pen event timestamp analysis

This CL adds a histogram that tracks the difference in input event
timestamp based on TimeTicks::Now and timestamp reported via
PerformanceCount. It will help analyze the distribution of how far
negative or positive TimeTicks::Now is compared to PerformanceCount.
This will help guide a decision on what timestamp to use in the future
for velocity calculation, input prediction, and gesture recognition.

For additional context, please see discussion at input-dev
https://groups.google.com/a/chromium.org/forum/#!topic/input-dev/KZMZ6dnzKZQ

Change-Id: I20dfee67b0ff959edcb0a81c551675f61b2549a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1666298
Commit-Queue: Sarthak Shah <sarsha@microsoft.com>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680244}
parent 4594dbd8
......@@ -37527,6 +37527,34 @@ uploading your change for review.
</summary>
</histogram>
<histogram
name="Event.Pen.InputEventTimeStamp.DeltaBetweenTimeNowAndPerformanceCount.Negative"
units="microseconds" expires_after="M79">
<owner>nzolghadr@chromium.org</owner>
<owner>sarsha@microsoft.com</owner>
<summary>
On Windows, reports negative time delta between pointer input timestamps
based on TimeNow and the timestamp reported via
PointerInfo.PerformanceCount. This negative time delta is w.r.t to
PerformanceCount. See also
Pen.InputEventTimeStamp.DeltaBetweenTimeNowAndPerformanceCount.Positive.
</summary>
</histogram>
<histogram
name="Event.Pen.InputEventTimeStamp.DeltaBetweenTimeNowAndPerformanceCount.Positive"
units="microseconds" expires_after="M79">
<owner>nzolghadr@chromium.org</owner>
<owner>sarsha@microsoft.com</owner>
<summary>
On Windows, reports positive time delta between pointer input timestamps
based on TimeNow and the timestamp reported via
PointerInfo.PerformanceCount. This positive time delta is w.r.t to
PerformanceCount. See also
Pen.InputEventTimeStamp.DeltaBetweenTimeNowAndPerformanceCount.Negative.
</summary>
</histogram>
<histogram name="Event.RenderView.DiscardInput" enum="BooleanHit"
expires_after="2017-06-26">
<obsolete>
......@@ -37639,6 +37667,34 @@ uploading your change for review.
</summary>
</histogram>
<histogram
name="Event.Touch.InputEventTimeStamp.DeltaBetweenTimeNowAndPerformanceCount.Negative"
units="microseconds" expires_after="M79">
<owner>nzolghadr@chromium.org</owner>
<owner>sarsha@microsoft.com</owner>
<summary>
On Windows, reports negative time delta between pointer input timestamps
based on TimeNow and the timestamp reported via
PointerInfo.PerformanceCount. This negative time delta is w.r.t to
PerformanceCount. See also
Touch.InputEventTimeStamp.DeltaBetweenTimeNowAndPerformanceCount.Positive.
</summary>
</histogram>
<histogram
name="Event.Touch.InputEventTimeStamp.DeltaBetweenTimeNowAndPerformanceCount.Positive"
units="microseconds" expires_after="M79">
<owner>nzolghadr@chromium.org</owner>
<owner>sarsha@microsoft.com</owner>
<summary>
On Windows, reports positive time delta between pointer input timestamps
based on TimeNow and the timestamp reported via
PointerInfo.PerformanceCount. This positive time delta is w.r.t to
PerformanceCount. See also
Touch.InputEventTimeStamp.DeltaBetweenTimeNowAndPerformanceCount.Negative.
</summary>
</histogram>
<histogram name="Event.Touch.TargetAndDispatchResult"
enum="TouchTargetAndDispatchResultType" expires_after="2016-05-19">
<obsolete>
......@@ -18,6 +18,7 @@
#include "base/location.h"
#include "base/macros.h"
#include "base/message_loop/message_loop_current.h"
#include "base/metrics/histogram_functions.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
......@@ -276,6 +277,49 @@ HitTest GetWindowResizeHitTest(UINT param) {
}
}
void RecordDeltaBetweenTimeNowAndPerformanceCountHistogram(
base::TimeTicks event_time,
UINT64 performance_count,
POINTER_INPUT_TYPE pointer_input_type,
bool is_session_remote) {
// In remote session, sometimes |performance_count| drifts
// substantially in future compared to |TimeTicks::Now()| - enough to skew the
// histogram data. Additionally, user input over remote session already has
// lag, so user is less likely to be sensitive to the responsiveness of input
// in such case. So we are less concerned capturing the deltas in remote
// session scenario.
if (base::TimeTicks::IsHighResolution() && !is_session_remote) {
base::TimeTicks event_time_from_pointer =
base::TimeTicks::FromQPCValue(performance_count);
double delta_between_event_timestamps =
(event_time - event_time_from_pointer).InMicrosecondsF();
std::string pointer_type;
switch (pointer_input_type) {
case PT_PEN:
pointer_type = "Pen";
break;
case PT_TOUCH:
pointer_type = "Touch";
break;
default:
NOTREACHED();
}
std::string number_sign =
delta_between_event_timestamps >= 0 ? "Positive" : "Negative";
base::TimeDelta delta_sample_value = base::TimeDelta::FromMicroseconds(
std::abs(delta_between_event_timestamps));
base::UmaHistogramCustomMicrosecondsTimes(
base::StringPrintf("Event.%s.InputEventTimeStamp."
"DeltaBetweenTimeNowAndPerformanceCount.%s",
pointer_type.c_str(), number_sign.c_str()),
delta_sample_value, base::TimeDelta::FromMicroseconds(1),
base::TimeDelta::FromMilliseconds(30), 30);
}
}
constexpr int kTouchDownContextResetTimeout = 500;
// Windows does not flag synthesized mouse messages from touch or pen in all
......@@ -408,6 +452,7 @@ HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate,
pointer_events_for_touch_(::features::IsUsingWMPointerForTouch()),
precision_touchpad_scroll_phase_enabled_(base::FeatureList::IsEnabled(
::features::kPrecisionTouchpadScrollPhase)),
is_remote_session_(base::win::IsCurrentSessionRemote()),
autohide_factory_(this) {}
HWNDMessageHandler::~HWNDMessageHandler() {
......@@ -2413,6 +2458,7 @@ void HWNDMessageHandler::OnSettingChange(UINT flags, const wchar_t* section) {
if (flags == SPI_SETWORKAREA)
delegate_->HandleWorkAreaChanged();
SetMsgHandled(FALSE);
is_remote_session_ = base::win::IsCurrentSessionRemote();
}
// If the work area is changing, then it could be as a result of the taskbar
......@@ -3041,6 +3087,10 @@ LRESULT HWNDMessageHandler::HandlePointerEventTypeTouch(UINT message,
base::WeakPtr<HWNDMessageHandler> ref(msg_handler_weak_factory_.GetWeakPtr());
delegate_->HandleTouchEvent(&event);
RecordDeltaBetweenTimeNowAndPerformanceCountHistogram(
event_time, pointer_info.PerformanceCount, pointer_info.pointerType,
is_remote_session_);
if (ref) {
// Mark touch released events handled. These will usually turn into tap
// gestures, and doing this avoids propagating the event to other windows.
......@@ -3090,12 +3140,16 @@ LRESULT HWNDMessageHandler::HandlePointerEventTypePen(UINT message,
// window, so use the weak ptr to check if destruction occured or not.
base::WeakPtr<HWNDMessageHandler> ref(msg_handler_weak_factory_.GetWeakPtr());
if (event) {
if (event->IsTouchEvent())
if (event->IsTouchEvent()) {
delegate_->HandleTouchEvent(event->AsTouchEvent());
else if (event->IsMouseEvent())
RecordDeltaBetweenTimeNowAndPerformanceCountHistogram(
event->time_stamp(), pointer_pen_info.pointerInfo.PerformanceCount,
pointer_pen_info.pointerInfo.pointerType, is_remote_session_);
} else if (event->IsMouseEvent()) {
delegate_->HandleMouseEvent(event->AsMouseEvent());
else
} else {
NOTREACHED();
}
last_touch_or_pen_message_time_ = ::GetMessageTime();
}
......
......@@ -764,6 +764,9 @@ class VIEWS_EXPORT HWNDMessageHandler : public gfx::WindowImpl,
// the first message after frame type changes.
bool needs_dwm_frame_clear_ = true;
// True if user is in remote session.
bool is_remote_session_;
// This is a map of the HMONITOR to full screeen window instance. It is safe
// to keep a raw pointer to the HWNDMessageHandler instance as we track the
// window destruction and ensure that the map is cleaned up.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment