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

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

Issue 2492793004: Add TimeToScrollUpdateSwapBegin2 in RAPPOR (Closed)
Patch Set: Rebase Created 4 years, 1 month 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_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "components/rappor/rappor_service.h"
12 #include "content/browser/renderer_host/render_widget_host_impl.h" 13 #include "content/browser/renderer_host/render_widget_host_impl.h"
13 #include "ui/events/blink/web_input_event_traits.h" 14 #include "ui/events/blink/web_input_event_traits.h"
14 15
15 using blink::WebGestureEvent; 16 using blink::WebGestureEvent;
16 using blink::WebInputEvent; 17 using blink::WebInputEvent;
17 using blink::WebMouseEvent; 18 using blink::WebMouseEvent;
18 using blink::WebMouseWheelEvent; 19 using blink::WebMouseWheelEvent;
19 using blink::WebTouchEvent; 20 using blink::WebTouchEvent;
20 using ui::LatencyInfo; 21 using ui::LatencyInfo;
21 22
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 231
231 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( 232 UMA_HISTOGRAM_SCROLL_LATENCY_LONG(
232 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", 233 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap",
233 browser_received_swap_component, gpu_swap_begin_component); 234 browser_received_swap_component, gpu_swap_begin_component);
234 235
235 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", 236 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap",
236 gpu_swap_begin_component, 237 gpu_swap_begin_component,
237 gpu_swap_end_component); 238 gpu_swap_end_component);
238 } 239 }
239 240
241 uint64_t RapporHistogramBucketIndex(int64_t ms) {
242 if (ms < 10)
243 return 0;
244 if (ms < 20)
245 return 1;
246 if (ms < 30)
247 return 2;
248 if (ms < 40)
249 return 3;
250 if (ms < 50)
251 return 4;
252 if (ms < 60)
253 return 5;
ncarter (slow) 2016/12/01 23:33:46 What about 6?
Navid Zolghadr 2016/12/08 17:37:29 This is now removed as I reported it without any b
254 return 7;
255 }
256
240 void ComputeTouchAndWheelScrollLatencyHistograms( 257 void ComputeTouchAndWheelScrollLatencyHistograms(
258 RenderWidgetHostImpl* render_widget_host_impl,
241 const ui::LatencyInfo::LatencyComponent& gpu_swap_begin_component, 259 const ui::LatencyInfo::LatencyComponent& gpu_swap_begin_component,
242 const ui::LatencyInfo::LatencyComponent& gpu_swap_end_component, 260 const ui::LatencyInfo::LatencyComponent& gpu_swap_end_component,
243 int64_t latency_component_id, 261 int64_t latency_component_id,
244 const ui::LatencyInfo& latency, 262 const ui::LatencyInfo& latency,
245 const std::string event_type_name) { 263 const std::string event_type_name) {
246 DCHECK(!latency.coalesced()); 264 DCHECK(!latency.coalesced());
247 if (latency.coalesced()) 265 if (latency.coalesced())
248 return; 266 return;
249 267
250 LatencyInfo::LatencyComponent original_component; 268 LatencyInfo::LatencyComponent original_component;
(...skipping 11 matching lines...) Expand all
262 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 280 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
263 latency_component_id, &original_component)) { 281 latency_component_id, &original_component)) {
264 // This UMA metric tracks the time from when the original touch event is 282 // This UMA metric tracks the time from when the original touch event is
265 // created to when the scroll gesture results in final frame swap. 283 // created to when the scroll gesture results in final frame swap.
266 // First scroll events are excluded from this metric. 284 // First scroll events are excluded from this metric.
267 if (event_type_name == "Touch") { 285 if (event_type_name == "Touch") {
268 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY( 286 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY(
269 "Event.Latency.ScrollUpdate." + event_type_name + 287 "Event.Latency.ScrollUpdate." + event_type_name +
270 ".TimeToScrollUpdateSwapBegin2", 288 ".TimeToScrollUpdateSwapBegin2",
271 original_component, gpu_swap_begin_component); 289 original_component, gpu_swap_begin_component);
290
291 if (!render_widget_host_impl->delegate())
292 return;
293 rappor::RapporService* rappor_service =
294 render_widget_host_impl->delegate()->getRapporService();
295 if (!rappor_service)
296 return;
297 std::unique_ptr<rappor::Sample> sample =
298 rappor_service->CreateSample(rappor::UMA_RAPPOR_TYPE);
299 sample->SetStringField(
300 "Domain",
301 render_widget_host_impl->delegate()->getRapporCommittedUrl());
Navid Zolghadr 2016/11/10 21:49:19 I was going to create some helper methods in my ne
Steven Holte 2016/11/10 22:49:45 It seems like this value is non-PII, so it should
Navid Zolghadr 2016/12/08 17:37:29 Done. I didn't find anywhere else that this is use
302 uint64_t bucket_index =
303 RapporHistogramBucketIndex((gpu_swap_begin_component.last_event_time -
304 original_component.first_event_time)
305 .InMicroseconds());
306 sample->SetFlagsField("Bucket", uint64_t(1) << bucket_index, 7);
307 rappor_service->RecordSampleObj(
308 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2."
309 "Rappor",
310 std::move(sample));
272 } 311 }
273 } else { 312 } else {
274 // No original component found. 313 // No original component found.
275 return; 314 return;
276 } 315 }
277 316
278 LatencyInfo::LatencyComponent rendering_scheduled_component; 317 LatencyInfo::LatencyComponent rendering_scheduled_component;
279 bool rendering_scheduled_on_main = latency.FindLatency( 318 bool rendering_scheduled_on_main = latency.FindLatency(
280 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, 319 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0,
281 &rendering_scheduled_component); 320 &rendering_scheduled_component);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 new_components_key[i].first, 388 new_components_key[i].first,
350 new_components_key[i].second, 389 new_components_key[i].second,
351 new_components_value[i].sequence_number, 390 new_components_value[i].sequence_number,
352 new_components_value[i].event_time, 391 new_components_value[i].event_time,
353 new_components_value[i].event_count); 392 new_components_value[i].event_count);
354 } 393 }
355 } 394 }
356 395
357 } // namespace 396 } // namespace
358 397
359 RenderWidgetHostLatencyTracker::RenderWidgetHostLatencyTracker() 398 RenderWidgetHostLatencyTracker::RenderWidgetHostLatencyTracker(
399 RenderWidgetHostImpl* render_widget_host_impl)
360 : last_event_id_(0), 400 : last_event_id_(0),
361 latency_component_id_(0), 401 latency_component_id_(0),
362 device_scale_factor_(1), 402 device_scale_factor_(1),
363 has_seen_first_gesture_scroll_update_(false), 403 has_seen_first_gesture_scroll_update_(false),
364 multi_finger_gesture_(false), 404 multi_finger_gesture_(false),
365 touch_start_default_prevented_(false) {} 405 touch_start_default_prevented_(false),
406 render_widget_host_impl(render_widget_host_impl) {}
366 407
367 RenderWidgetHostLatencyTracker::~RenderWidgetHostLatencyTracker() {} 408 RenderWidgetHostLatencyTracker::~RenderWidgetHostLatencyTracker() {}
368 409
369 void RenderWidgetHostLatencyTracker::Initialize(int routing_id, 410 void RenderWidgetHostLatencyTracker::Initialize(int routing_id,
370 int process_id) { 411 int process_id) {
371 DCHECK_EQ(0, last_event_id_); 412 DCHECK_EQ(0, last_event_id_);
372 DCHECK_EQ(0, latency_component_id_); 413 DCHECK_EQ(0, latency_component_id_);
373 last_event_id_ = static_cast<int64_t>(process_id) << 32; 414 last_event_id_ = static_cast<int64_t>(process_id) << 32;
374 latency_component_id_ = routing_id | last_event_id_; 415 latency_component_id_ = routing_id | last_event_id_;
375 } 416 }
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 735
695 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 736 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
696 latency_component_id_, nullptr)) { 737 latency_component_id_, nullptr)) {
697 return; 738 return;
698 } 739 }
699 740
700 ui::SourceEventType source_event_type = latency.source_event_type(); 741 ui::SourceEventType source_event_type = latency.source_event_type();
701 if (source_event_type == ui::SourceEventType::WHEEL || 742 if (source_event_type == ui::SourceEventType::WHEEL ||
702 source_event_type == ui::SourceEventType::TOUCH) { 743 source_event_type == ui::SourceEventType::TOUCH) {
703 ComputeTouchAndWheelScrollLatencyHistograms( 744 ComputeTouchAndWheelScrollLatencyHistograms(
704 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_, 745 render_widget_host_impl, gpu_swap_begin_component,
705 latency, 746 gpu_swap_end_component, latency_component_id_, latency,
706 source_event_type == ui::SourceEventType::WHEEL ? "Wheel" : "Touch"); 747 source_event_type == ui::SourceEventType::WHEEL ? "Wheel" : "Touch");
707 } 748 }
708 749
709 // Compute the old scroll update latency metrics. They are exclusively 750 // Compute the old scroll update latency metrics. They are exclusively
710 // calculated for touch scrolls, and will be deprecated on M56. 751 // calculated for touch scrolls, and will be deprecated on M56.
711 // (https://crbug.com/649754) 752 // (https://crbug.com/649754)
712 LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component; 753 LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component;
713 if (!latency.FindLatency( 754 if (!latency.FindLatency(
714 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, 755 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0,
715 &mouse_wheel_scroll_update_component)) { 756 &mouse_wheel_scroll_update_component)) {
716 ComputeScrollLatencyHistograms( 757 ComputeScrollLatencyHistograms(
717 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_, 758 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_,
718 latency, is_running_navigation_hint_task); 759 latency, is_running_navigation_hint_task);
719 } 760 }
720 } 761 }
721 762
722 } // namespace content 763 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698