Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: content/browser/renderer_host/input/render_widget_host_latency_tracker.cc

Issue 2914023002: Remove LatencyInfo::sequence_number. (May break metrics).
Patch Set: Rebase Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker .h" 5 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker .h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_functions.h" 10 #include "base/metrics/histogram_functions.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 // Remove the entries with invalid component IDs. 64 // Remove the entries with invalid component IDs.
65 latency->RemoveLatency(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT); 65 latency->RemoveLatency(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT);
66 66
67 // Add newly generated components into the latency info 67 // Add newly generated components into the latency info
68 for (size_t i = 0; i < new_components_key.size(); i++) { 68 for (size_t i = 0; i < new_components_key.size(); i++) {
69 latency->AddLatencyNumberWithTimestamp( 69 latency->AddLatencyNumberWithTimestamp(
70 new_components_key[i].first, 70 new_components_key[i].first,
71 new_components_key[i].second, 71 new_components_key[i].second,
72 new_components_value[i].sequence_number,
73 new_components_value[i].event_time, 72 new_components_value[i].event_time,
74 new_components_value[i].event_count); 73 new_components_value[i].event_count);
75 } 74 }
76 } 75 }
77 76
78 void RecordEQTAccuracy(base::TimeDelta queueing_time, 77 void RecordEQTAccuracy(base::TimeDelta queueing_time,
79 base::TimeDelta expected_queueing_time) { 78 base::TimeDelta expected_queueing_time) {
80 float expected_queueing_time_ms = expected_queueing_time.InMillisecondsF(); 79 float expected_queueing_time_ms = expected_queueing_time.InMillisecondsF();
81 80
82 if (expected_queueing_time_ms < 10) { 81 if (expected_queueing_time_ms < 10) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 "RendererScheduler." 132 "RendererScheduler."
134 "QueueingDurationWhenExpectedQueueingTime_GreaterThan.450ms", 133 "QueueingDurationWhenExpectedQueueingTime_GreaterThan.450ms",
135 queueing_time); 134 queueing_time);
136 } 135 }
137 } 136 }
138 137
139 } // namespace 138 } // namespace
140 139
141 RenderWidgetHostLatencyTracker::RenderWidgetHostLatencyTracker() 140 RenderWidgetHostLatencyTracker::RenderWidgetHostLatencyTracker()
142 : ukm_source_id_(-1), 141 : ukm_source_id_(-1),
143 last_event_id_(0),
144 latency_component_id_(0), 142 latency_component_id_(0),
145 device_scale_factor_(1), 143 device_scale_factor_(1),
146 has_seen_first_gesture_scroll_update_(false), 144 has_seen_first_gesture_scroll_update_(false),
147 active_multi_finger_gesture_(false), 145 active_multi_finger_gesture_(false),
148 touch_start_default_prevented_(false), 146 touch_start_default_prevented_(false),
149 render_widget_host_delegate_(nullptr) {} 147 render_widget_host_delegate_(nullptr) {}
150 148
151 RenderWidgetHostLatencyTracker::~RenderWidgetHostLatencyTracker() {} 149 RenderWidgetHostLatencyTracker::~RenderWidgetHostLatencyTracker() {}
152 150
153 void RenderWidgetHostLatencyTracker::Initialize(int routing_id, 151 void RenderWidgetHostLatencyTracker::Initialize(int routing_id,
154 int process_id) { 152 int process_id) {
155 DCHECK_EQ(0, last_event_id_);
156 DCHECK_EQ(0, latency_component_id_); 153 DCHECK_EQ(0, latency_component_id_);
157 last_event_id_ = static_cast<int64_t>(process_id) << 32; 154 latency_component_id_ = routing_id | static_cast<int64_t>(process_id) << 32;
158 latency_component_id_ = routing_id | last_event_id_;
159 } 155 }
160 156
161 void RenderWidgetHostLatencyTracker::ComputeInputLatencyHistograms( 157 void RenderWidgetHostLatencyTracker::ComputeInputLatencyHistograms(
162 WebInputEvent::Type type, 158 WebInputEvent::Type type,
163 int64_t latency_component_id, 159 int64_t latency_component_id,
164 const LatencyInfo& latency, 160 const LatencyInfo& latency,
165 InputEventAckState ack_result) { 161 InputEventAckState ack_result) {
166 // If this event was coalesced into another event, ignore it, as the event it 162 // If this event was coalesced into another event, ignore it, as the event it
167 // was coalesced into will reflect the full latency. 163 // was coalesced into will reflect the full latency.
168 if (latency.coalesced()) 164 if (latency.coalesced())
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // Timestamp from platform input can wrap, e.g. 32 bits timestamp 288 // Timestamp from platform input can wrap, e.g. 32 bits timestamp
293 // for Xserver and Window MSG time will wrap about 49.6 days. Do a 289 // for Xserver and Window MSG time will wrap about 49.6 days. Do a
294 // sanity check here and if wrap does happen, use TimeTicks::Now() 290 // sanity check here and if wrap does happen, use TimeTicks::Now()
295 // as the timestamp instead. 291 // as the timestamp instead.
296 if ((timestamp_now - timestamp_original).InDays() > 0) 292 if ((timestamp_now - timestamp_original).InDays() > 0)
297 timestamp_original = timestamp_now; 293 timestamp_original = timestamp_now;
298 294
299 latency->AddLatencyNumberWithTimestamp( 295 latency->AddLatencyNumberWithTimestamp(
300 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 296 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
301 0, 297 0,
302 0,
303 timestamp_original, 298 timestamp_original,
304 1); 299 1);
305 } 300 }
306 301
307 latency->AddLatencyNumberWithTraceName( 302 latency->AddLatencyNumberWithTraceName(
308 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, latency_component_id_, 303 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, latency_component_id_,
309 ++last_event_id_, WebInputEvent::GetName(event.GetType())); 304 WebInputEvent::GetName(event.GetType()));
310 305
311 if (event.GetType() == blink::WebInputEvent::kGestureScrollBegin) { 306 if (event.GetType() == blink::WebInputEvent::kGestureScrollBegin) {
312 has_seen_first_gesture_scroll_update_ = false; 307 has_seen_first_gesture_scroll_update_ = false;
313 } else if (event.GetType() == blink::WebInputEvent::kGestureScrollUpdate) { 308 } else if (event.GetType() == blink::WebInputEvent::kGestureScrollUpdate) {
314 // Make a copy of the INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT with a 309 // Make a copy of the INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT with a
315 // different name INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT. 310 // different name INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT.
316 // So we can track the latency specifically for scroll update events. 311 // So we can track the latency specifically for scroll update events.
317 LatencyInfo::LatencyComponent original_component; 312 LatencyInfo::LatencyComponent original_component;
318 if (latency->FindLatency(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 313 if (latency->FindLatency(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0,
319 &original_component)) { 314 &original_component)) {
320 latency->AddLatencyNumberWithTimestamp( 315 latency->AddLatencyNumberWithTimestamp(
321 has_seen_first_gesture_scroll_update_ 316 has_seen_first_gesture_scroll_update_
322 ? ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT 317 ? ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT
323 : ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 318 : ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
324 latency_component_id_, original_component.sequence_number, 319 latency_component_id_, original_component.event_time,
325 original_component.event_time, original_component.event_count); 320 original_component.event_count);
326 } 321 }
327 322
328 has_seen_first_gesture_scroll_update_ = true; 323 has_seen_first_gesture_scroll_update_ = true;
329 } 324 }
330 } 325 }
331 326
332 void RenderWidgetHostLatencyTracker::OnInputEventAck( 327 void RenderWidgetHostLatencyTracker::OnInputEventAck(
333 const blink::WebInputEvent& event, 328 const blink::WebInputEvent& event,
334 LatencyInfo* latency, InputEventAckState ack_result) { 329 LatencyInfo* latency, InputEventAckState ack_result) {
335 DCHECK(latency); 330 DCHECK(latency);
336 331
337 // Latency ends if an event is acked but does not cause render scheduling. 332 // Latency ends if an event is acked but does not cause render scheduling.
338 bool rendering_scheduled = latency->FindLatency( 333 bool rendering_scheduled = latency->FindLatency(
339 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, nullptr); 334 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, nullptr);
340 rendering_scheduled |= latency->FindLatency( 335 rendering_scheduled |= latency->FindLatency(
341 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, nullptr); 336 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, nullptr);
342 337
343 if (WebInputEvent::IsTouchEventType(event.GetType())) { 338 if (WebInputEvent::IsTouchEventType(event.GetType())) {
344 const WebTouchEvent& touch_event = 339 const WebTouchEvent& touch_event =
345 *static_cast<const WebTouchEvent*>(&event); 340 *static_cast<const WebTouchEvent*>(&event);
346 if (event.GetType() == WebInputEvent::kTouchStart) { 341 if (event.GetType() == WebInputEvent::kTouchStart) {
347 touch_start_default_prevented_ = 342 touch_start_default_prevented_ =
348 ack_result == INPUT_EVENT_ACK_STATE_CONSUMED; 343 ack_result == INPUT_EVENT_ACK_STATE_CONSUMED;
349 } else if (event.GetType() == WebInputEvent::kTouchEnd || 344 } else if (event.GetType() == WebInputEvent::kTouchEnd ||
350 event.GetType() == WebInputEvent::kTouchCancel) { 345 event.GetType() == WebInputEvent::kTouchCancel) {
351 active_multi_finger_gesture_ = touch_event.touches_length > 2; 346 active_multi_finger_gesture_ = touch_event.touches_length > 2;
352 } 347 }
353 } 348 }
354 349
355 latency->AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0); 350 latency->AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0);
356 // If this event couldn't have caused a gesture event, and it didn't trigger 351 // If this event couldn't have caused a gesture event, and it didn't trigger
357 // rendering, we're done processing it. 352 // rendering, we're done processing it.
358 if (!rendering_scheduled) { 353 if (!rendering_scheduled) {
359 latency->AddLatencyNumber( 354 latency->AddLatencyNumber(
360 ui::INPUT_EVENT_LATENCY_TERMINATED_NO_SWAP_COMPONENT, 0, 0); 355 ui::INPUT_EVENT_LATENCY_TERMINATED_NO_SWAP_COMPONENT, 0);
361 } 356 }
362 357
363 ComputeInputLatencyHistograms(event.GetType(), latency_component_id_, 358 ComputeInputLatencyHistograms(event.GetType(), latency_component_id_,
364 *latency, ack_result); 359 *latency, ack_result);
365 } 360 }
366 361
367 void RenderWidgetHostLatencyTracker::OnSwapCompositorFrame( 362 void RenderWidgetHostLatencyTracker::OnSwapCompositorFrame(
368 std::vector<LatencyInfo>* latencies) { 363 std::vector<LatencyInfo>* latencies) {
369 DCHECK(latencies); 364 DCHECK(latencies);
370 for (LatencyInfo& latency : *latencies) { 365 for (LatencyInfo& latency : *latencies) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 if (ukm_source_id == -1 || !ukm_recorder) 415 if (ukm_source_id == -1 || !ukm_recorder)
421 return; 416 return;
422 417
423 std::unique_ptr<ukm::UkmEntryBuilder> builder = 418 std::unique_ptr<ukm::UkmEntryBuilder> builder =
424 ukm_recorder->GetEntryBuilder(ukm_source_id, event_name.c_str()); 419 ukm_recorder->GetEntryBuilder(ukm_source_id, event_name.c_str());
425 builder->AddMetric(metric_name.c_str(), (end_component.last_event_time - 420 builder->AddMetric(metric_name.c_str(), (end_component.last_event_time -
426 start_component.first_event_time) 421 start_component.first_event_time)
427 .InMicroseconds()); 422 .InMicroseconds());
428 } 423 }
429 } // namespace content 424 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698