Chromium Code Reviews| Index: content/browser/renderer_host/input/render_widget_host_latency_tracker.cc |
| diff --git a/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc b/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc |
| index e2ef1e441c80b81c95d5add1c22e53600cc3e2d4..d703b0e7d09fcf784b82afc2272f2044cc9be2a6 100644 |
| --- a/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc |
| +++ b/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc |
| @@ -75,66 +75,6 @@ void UpdateLatencyCoordinates(const WebInputEvent& event, |
| } |
| } |
| -void ComputeInputLatencyHistograms(WebInputEvent::Type type, |
| - int64_t latency_component_id, |
| - const LatencyInfo& latency) { |
| - if (latency.coalesced()) |
| - return; |
| - |
| - LatencyInfo::LatencyComponent rwh_component; |
| - if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| - latency_component_id, &rwh_component)) { |
| - return; |
| - } |
| - DCHECK_EQ(rwh_component.event_count, 1u); |
| - |
| - LatencyInfo::LatencyComponent ui_component; |
| - if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, |
| - &ui_component)) { |
| - DCHECK_EQ(ui_component.event_count, 1u); |
| - base::TimeDelta ui_delta = |
| - rwh_component.event_time - ui_component.event_time; |
| - switch (type) { |
| - case blink::WebInputEvent::MouseWheel: |
| - UMA_HISTOGRAM_CUSTOM_COUNTS( |
| - "Event.Latency.Browser.WheelUI", |
| - ui_delta.InMicroseconds(), 1, 20000, 100); |
| - break; |
| - case blink::WebInputEvent::TouchTypeFirst: |
| - UMA_HISTOGRAM_CUSTOM_COUNTS( |
| - "Event.Latency.Browser.TouchUI", |
| - ui_delta.InMicroseconds(), 1, 20000, 100); |
| - break; |
| - default: |
| - NOTREACHED(); |
| - break; |
| - } |
| - } |
| - |
| - LatencyInfo::LatencyComponent acked_component; |
| - if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, |
| - &acked_component)) { |
| - DCHECK_EQ(acked_component.event_count, 1u); |
| - base::TimeDelta acked_delta = |
| - acked_component.event_time - rwh_component.event_time; |
| - switch (type) { |
| - case blink::WebInputEvent::MouseWheel: |
| - UMA_HISTOGRAM_CUSTOM_COUNTS( |
| - "Event.Latency.Browser.WheelAcked", |
| - acked_delta.InMicroseconds(), 1, 1000000, 100); |
| - break; |
| - case blink::WebInputEvent::TouchTypeFirst: |
| - UMA_HISTOGRAM_CUSTOM_COUNTS( |
| - "Event.Latency.Browser.TouchAcked", |
| - acked_delta.InMicroseconds(), 1, 1000000, 100); |
| - break; |
| - default: |
| - NOTREACHED(); |
| - break; |
| - } |
| - } |
| -} |
| - |
| // Touch to scroll latency that is mostly under 1 second. |
| #define UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY(name, start, end) \ |
| UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| @@ -287,11 +227,11 @@ RenderWidgetHostLatencyTracker::RenderWidgetHostLatencyTracker() |
| : last_event_id_(0), |
| latency_component_id_(0), |
| device_scale_factor_(1), |
| - has_seen_first_gesture_scroll_update_(false) { |
| -} |
| + has_seen_first_gesture_scroll_update_(false), |
| + multi_finger_gesture_(false), |
| + touch_start_default_prevented_(false) {} |
| -RenderWidgetHostLatencyTracker::~RenderWidgetHostLatencyTracker() { |
| -} |
| +RenderWidgetHostLatencyTracker::~RenderWidgetHostLatencyTracker() {} |
| void RenderWidgetHostLatencyTracker::Initialize(int routing_id, |
| int process_id) { |
| @@ -301,6 +241,95 @@ void RenderWidgetHostLatencyTracker::Initialize(int routing_id, |
| latency_component_id_ = routing_id | last_event_id_; |
| } |
| +void RenderWidgetHostLatencyTracker::ComputeInputLatencyHistograms( |
| + WebInputEvent::Type type, |
| + int64_t latency_component_id, |
| + const LatencyInfo& latency, |
| + bool default_prevented) { |
| + if (latency.coalesced()) |
| + return; |
| + |
| + LatencyInfo::LatencyComponent rwh_component; |
| + if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| + latency_component_id, &rwh_component)) { |
| + return; |
| + } |
| + DCHECK_EQ(rwh_component.event_count, 1u); |
| + |
| + LatencyInfo::LatencyComponent ui_component; |
| + if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, |
| + &ui_component)) { |
| + DCHECK_EQ(ui_component.event_count, 1u); |
| + base::TimeDelta ui_delta = |
| + rwh_component.event_time - ui_component.event_time; |
| + |
| + if (type == blink::WebInputEvent::MouseWheel) { |
| + UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.WheelUI", |
| + ui_delta.InMicroseconds(), 1, 20000, 100); |
| + |
| + } else { |
| + DCHECK(WebInputEvent::isTouchEventType(type)); |
| + UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.TouchUI", |
| + ui_delta.InMicroseconds(), 1, 20000, 100); |
| + } |
| + } |
| + |
| + LatencyInfo::LatencyComponent dispatched_to_renderer_component; |
| + if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_REACHED_RWH_COMPONENT, 0, |
| + &dispatched_to_renderer_component)) { |
| + DCHECK_EQ(dispatched_to_renderer_component.event_count, 1u); |
| + base::TimeDelta queueing_delta = |
| + dispatched_to_renderer_component.event_time - rwh_component.event_time; |
| + if (type == WebInputEvent::TouchMove && !multi_finger_gesture_) { |
| + if (touch_start_default_prevented_ || default_prevented) { |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( |
| + "Event.Latency.QueueingTime.TouchMoveDefaultPrevented", |
| + queueing_delta.InMicroseconds(), 1, 1000000, 100); |
| + } else { |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( |
| + "Event.Latency.QueueingTime.TouchMoveDefaultAllowed", |
| + queueing_delta.InMicroseconds(), 1, 1000000, 100); |
| + } |
| + } |
| + } |
| + |
| + LatencyInfo::LatencyComponent acked_component; |
| + if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, |
| + &acked_component)) { |
| + DCHECK_EQ(acked_component.event_count, 1u); |
| + base::TimeDelta acked_delta = |
| + acked_component.event_time - rwh_component.event_time; |
| + if (type == blink::WebInputEvent::MouseWheel) { |
| + UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.WheelAcked", |
| + acked_delta.InMicroseconds(), 1, 1000000, |
| + 100); |
| + } else { |
| + DCHECK(WebInputEvent::isTouchEventType(type)); |
| + UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.TouchAcked", |
| + acked_delta.InMicroseconds(), 1, 1000000, |
| + 100); |
| + } |
| + |
| + if (type == WebInputEvent::TouchMove && !multi_finger_gesture_) { |
| + base::TimeDelta blocking_delta; |
| + if (dispatched_to_renderer_component.event_time != base::TimeTicks()) { |
| + blocking_delta = acked_component.event_time - |
| + dispatched_to_renderer_component.event_time; |
| + } |
| + |
| + if (touch_start_default_prevented_ || default_prevented) { |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( |
| + "Event.Latency.BlockingTime.TouchMoveDefaultPrevented", |
| + blocking_delta.InMicroseconds(), 1, 1000000, 100); |
| + } else { |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( |
| + "Event.Latency.BlockingTime.TouchMoveDefaultAllowed", |
| + blocking_delta.InMicroseconds(), 1, 1000000, 100); |
|
Ilya Sherman
2016/04/06 01:34:54
Do you need 100 buckets, or would 50 suffice?
tdresser
2016/05/19 20:48:08
Done.
|
| + } |
| + } |
| + } |
| +} |
| + |
| void RenderWidgetHostLatencyTracker::OnInputEvent( |
| const blink::WebInputEvent& event, |
| LatencyInfo* latency) { |
| @@ -360,9 +389,19 @@ void RenderWidgetHostLatencyTracker::OnInputEvent( |
| } |
| } |
| +void RenderWidgetHostLatencyTracker::OnForwardEventToRenderer( |
| + const blink::WebInputEvent& event, |
| + ui::LatencyInfo* latency) { |
| + DCHECK(latency); |
| + if (WebInputEvent::isTouchEventType(event.type)) { |
| + latency->AddLatencyNumber(ui::INPUT_EVENT_LATENCY_REACHED_RWH_COMPONENT, 0, |
| + 0); |
| + } |
| +} |
| + |
| void RenderWidgetHostLatencyTracker::OnInputEventAck( |
| const blink::WebInputEvent& event, |
| - LatencyInfo* latency) { |
| + LatencyInfo* latency, bool defaultPrevented) { |
| DCHECK(latency); |
| // Latency ends when it is acked but does not cause render scheduling. |
| @@ -381,13 +420,22 @@ void RenderWidgetHostLatencyTracker::OnInputEventAck( |
| } |
| if (WebInputEvent::isTouchEventType(event.type)) { |
| + const WebTouchEvent& touch_event = |
| + *static_cast<const WebTouchEvent*>(&event); |
| + if (event.type == WebInputEvent::TouchStart) { |
| + DCHECK(touch_event.touchesLength >= 1); |
| + multi_finger_gesture_ = touch_event.touchesLength != 1; |
| + touch_start_default_prevented_ = defaultPrevented; |
| + } |
| + |
| latency->AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0); |
| + |
| if (!rendering_scheduled) { |
| latency->AddLatencyNumber( |
| ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, 0); |
| } |
| - ComputeInputLatencyHistograms(WebInputEvent::TouchTypeFirst, |
| - latency_component_id_, *latency); |
| + ComputeInputLatencyHistograms(event.type, latency_component_id_, *latency, |
| + defaultPrevented); |
| return; |
| } |
| @@ -397,8 +445,8 @@ void RenderWidgetHostLatencyTracker::OnInputEventAck( |
| latency->AddLatencyNumber( |
| ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_WHEEL_COMPONENT, 0, 0); |
| } |
| - ComputeInputLatencyHistograms(WebInputEvent::MouseWheel, |
| - latency_component_id_, *latency); |
| + ComputeInputLatencyHistograms(event.type, latency_component_id_, *latency, |
| + defaultPrevented); |
| return; |
| } |