| OLD | NEW |
| 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.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT(name, start, end) \ | 89 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT(name, start, end) \ |
| 90 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 90 UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 91 name, \ | 91 name, \ |
| 92 (end.event_time - start.event_time).InMicroseconds(), \ | 92 (end.event_time - start.event_time).InMicroseconds(), \ |
| 93 1, 50000, 50) | 93 1, 50000, 50) |
| 94 | 94 |
| 95 void ComputeScrollLatencyHistograms( | 95 void ComputeScrollLatencyHistograms( |
| 96 const LatencyInfo::LatencyComponent& gpu_swap_begin_component, | 96 const LatencyInfo::LatencyComponent& gpu_swap_begin_component, |
| 97 const LatencyInfo::LatencyComponent& gpu_swap_end_component, | 97 const LatencyInfo::LatencyComponent& gpu_swap_end_component, |
| 98 int64_t latency_component_id, | 98 int64_t latency_component_id, |
| 99 const LatencyInfo& latency) { | 99 const LatencyInfo& latency, |
| 100 bool is_running_navigation_hint_task) { |
| 100 DCHECK(!latency.coalesced()); | 101 DCHECK(!latency.coalesced()); |
| 101 if (latency.coalesced()) | 102 if (latency.coalesced()) |
| 102 return; | 103 return; |
| 103 | 104 |
| 104 DCHECK(!gpu_swap_begin_component.event_time.is_null()); | 105 DCHECK(!gpu_swap_begin_component.event_time.is_null()); |
| 105 DCHECK(!gpu_swap_end_component.event_time.is_null()); | 106 DCHECK(!gpu_swap_end_component.event_time.is_null()); |
| 106 LatencyInfo::LatencyComponent original_component; | 107 LatencyInfo::LatencyComponent original_component; |
| 107 if (latency.FindLatency( | 108 if (latency.FindLatency( |
| 108 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 109 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| 109 latency_component_id, &original_component)) { | 110 latency_component_id, &original_component)) { |
| 110 // This UMA metric tracks the time between the final frame swap for the | 111 // This UMA metric tracks the time between the final frame swap for the |
| 111 // first scroll event in a sequence and the original timestamp of that | 112 // first scroll event in a sequence and the original timestamp of that |
| 112 // scroll event's underlying touch event. | 113 // scroll event's underlying touch event. |
| 113 for (size_t i = 0; i < original_component.event_count; i++) { | 114 for (size_t i = 0; i < original_component.event_count; i++) { |
| 114 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | 115 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
| 115 "Event.Latency.TouchToFirstScrollUpdateSwapBegin", | 116 "Event.Latency.TouchToFirstScrollUpdateSwapBegin", |
| 116 original_component, gpu_swap_begin_component); | 117 original_component, gpu_swap_begin_component); |
| 117 } | 118 } |
| 119 // TODO(horo): IsRunningNavigationHintTask UMAs are only for |
| 120 // SpeculativeLaunchServiceWorker experimentation. So remove this UMA when |
| 121 // the experimentation finished (crbug.com/638827). |
| 122 if (is_running_navigation_hint_task) { |
| 123 for (size_t i = 0; i < original_component.event_count; i++) { |
| 124 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
| 125 "Event.Latency.TouchToFirstScrollUpdateSwapBegin_" |
| 126 "IsRunningNavigationHintTask", |
| 127 original_component, gpu_swap_begin_component); |
| 128 } |
| 129 } |
| 118 } else if (!latency.FindLatency( | 130 } else if (!latency.FindLatency( |
| 119 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 131 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| 120 latency_component_id, &original_component)) { | 132 latency_component_id, &original_component)) { |
| 121 return; | 133 return; |
| 122 } | 134 } |
| 123 | 135 |
| 124 // This UMA metric tracks the time from when the original touch event is | 136 // This UMA metric tracks the time from when the original touch event is |
| 125 // created to when the scroll gesture results in final frame swap. | 137 // created to when the scroll gesture results in final frame swap. |
| 126 for (size_t i = 0; i < original_component.event_count; i++) { | 138 for (size_t i = 0; i < original_component.event_count; i++) { |
| 127 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | 139 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
| 128 "Event.Latency.TouchToScrollUpdateSwapBegin", original_component, | 140 "Event.Latency.TouchToScrollUpdateSwapBegin", original_component, |
| 129 gpu_swap_begin_component); | 141 gpu_swap_begin_component); |
| 130 } | 142 } |
| 143 // TODO(horo): IsRunningNavigationHintTask UMAs are only for |
| 144 // SpeculativeLaunchServiceWorker experimentation. So remove this UMA when |
| 145 // the experimentation finished (crbug.com/638827). |
| 146 if (is_running_navigation_hint_task) { |
| 147 for (size_t i = 0; i < original_component.event_count; i++) { |
| 148 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
| 149 "Event.Latency.TouchToScrollUpdateSwapBegin_" |
| 150 "IsRunningNavigationHintTask", |
| 151 original_component, gpu_swap_begin_component); |
| 152 } |
| 153 } |
| 131 | 154 |
| 132 // TODO(miletus): Add validation for making sure the following components | 155 // TODO(miletus): Add validation for making sure the following components |
| 133 // are present and their event times are legit. | 156 // are present and their event times are legit. |
| 134 LatencyInfo::LatencyComponent rendering_scheduled_component; | 157 LatencyInfo::LatencyComponent rendering_scheduled_component; |
| 135 bool rendering_scheduled_on_main = latency.FindLatency( | 158 bool rendering_scheduled_on_main = latency.FindLatency( |
| 136 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, | 159 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, |
| 137 0, &rendering_scheduled_component); | 160 0, &rendering_scheduled_component); |
| 138 | 161 |
| 139 if (!rendering_scheduled_on_main) { | 162 if (!rendering_scheduled_on_main) { |
| 140 if (!latency.FindLatency( | 163 if (!latency.FindLatency( |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 std::vector<LatencyInfo>* latencies) { | 547 std::vector<LatencyInfo>* latencies) { |
| 525 DCHECK(latencies); | 548 DCHECK(latencies); |
| 526 for (LatencyInfo& latency : *latencies) { | 549 for (LatencyInfo& latency : *latencies) { |
| 527 AddLatencyInfoComponentIds(&latency, latency_component_id_); | 550 AddLatencyInfoComponentIds(&latency, latency_component_id_); |
| 528 latency.AddLatencyNumber( | 551 latency.AddLatencyNumber( |
| 529 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); | 552 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); |
| 530 } | 553 } |
| 531 } | 554 } |
| 532 | 555 |
| 533 void RenderWidgetHostLatencyTracker::OnFrameSwapped( | 556 void RenderWidgetHostLatencyTracker::OnFrameSwapped( |
| 534 const LatencyInfo& latency) { | 557 const LatencyInfo& latency, |
| 558 bool is_running_navigation_hint_task) { |
| 535 // Don't report frame latency on wheel events. Previously they were only | 559 // Don't report frame latency on wheel events. Previously they were only |
| 536 // reported on touch metrics and we need to be consistent across reporting | 560 // reported on touch metrics and we need to be consistent across reporting |
| 537 // metrics. | 561 // metrics. |
| 538 LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component; | 562 LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component; |
| 539 if (latency.FindLatency( | 563 if (latency.FindLatency( |
| 540 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, | 564 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, |
| 541 &mouse_wheel_scroll_update_component)) { | 565 &mouse_wheel_scroll_update_component)) { |
| 542 return; | 566 return; |
| 543 } | 567 } |
| 544 | 568 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 565 } | 589 } |
| 566 } | 590 } |
| 567 | 591 |
| 568 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 592 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| 569 latency_component_id_, nullptr)) { | 593 latency_component_id_, nullptr)) { |
| 570 return; | 594 return; |
| 571 } | 595 } |
| 572 | 596 |
| 573 ComputeScrollLatencyHistograms(gpu_swap_begin_component, | 597 ComputeScrollLatencyHistograms(gpu_swap_begin_component, |
| 574 gpu_swap_end_component, latency_component_id_, | 598 gpu_swap_end_component, latency_component_id_, |
| 575 latency); | 599 latency, is_running_navigation_hint_task); |
| 576 } | 600 } |
| 577 | 601 |
| 578 } // namespace content | 602 } // namespace content |
| OLD | NEW |