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_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 } else if (WebInputEvent::isTouchEventType(event.type)) { | 66 } else if (WebInputEvent::isTouchEventType(event.type)) { |
67 UpdateLatencyCoordinatesImpl(static_cast<const WebTouchEvent&>(event), | 67 UpdateLatencyCoordinatesImpl(static_cast<const WebTouchEvent&>(event), |
68 latency, device_scale_factor); | 68 latency, device_scale_factor); |
69 } else if (event.type == WebInputEvent::MouseWheel) { | 69 } else if (event.type == WebInputEvent::MouseWheel) { |
70 UpdateLatencyCoordinatesImpl(static_cast<const WebMouseWheelEvent&>(event), | 70 UpdateLatencyCoordinatesImpl(static_cast<const WebMouseWheelEvent&>(event), |
71 latency, device_scale_factor); | 71 latency, device_scale_factor); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 // Touch to scroll latency that is mostly under 1 second. | 75 // Touch to scroll latency that is mostly under 1 second. |
76 #define UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY(name, start, end) \ | 76 #define UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY(is_first, name, start, end) \ |
77 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 77 UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
78 name, (end.event_time - start.event_time).InMicroseconds(), 1, 1000000, \ | 78 base::StringPrintf(name, ""), \ |
tdresser
2016/09/08 15:17:25
Do we need this StringPrintf? Couldn't we just pas
| |
79 100) | 79 (end.event_time - start.event_time).InMicroseconds(), 1, 1000000, 100); \ |
80 if (is_first) { \ | |
81 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | |
82 base::StringPrintf(name, "First"), \ | |
83 (end.event_time - start.event_time).InMicroseconds(), 1, 1000000, \ | |
84 100); \ | |
85 } | |
80 | 86 |
81 // Long scroll latency component that is mostly under 200ms. | 87 // Long scroll latency component that is mostly under 200ms. |
82 #define UMA_HISTOGRAM_SCROLL_LATENCY_LONG(name, start, end) \ | 88 #define UMA_HISTOGRAM_SCROLL_LATENCY_LONG(is_first, name, start, end) \ |
83 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 89 UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
84 name, \ | 90 base::StringPrintf(name, ""), \ |
85 (end.event_time - start.event_time).InMicroseconds(), \ | 91 (end.event_time - start.event_time).InMicroseconds(), 1000, 200000, 50); \ |
86 1000, 200000, 50) | 92 if (is_first) { \ |
93 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | |
94 base::StringPrintf(name, "First"), \ | |
95 (end.event_time - start.event_time).InMicroseconds(), 1000, 200000, \ | |
96 50); \ | |
97 } | |
87 | 98 |
88 // Short scroll latency component that is mostly under 50ms. | 99 // Short scroll latency component that is mostly under 50ms. |
89 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT(name, start, end) \ | 100 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT(is_first, name, start, end) \ |
90 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 101 UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
91 name, \ | 102 base::StringPrintf(name, ""), \ |
92 (end.event_time - start.event_time).InMicroseconds(), \ | 103 (end.event_time - start.event_time).InMicroseconds(), 1, 50000, 50); \ |
93 1, 50000, 50) | 104 if (is_first) { \ |
105 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | |
106 base::StringPrintf(name, "First"), \ | |
107 (end.event_time - start.event_time).InMicroseconds(), 1, 50000, 50); \ | |
108 } | |
94 | 109 |
95 void ComputeScrollLatencyHistograms( | 110 void ComputeScrollLatencyHistograms( |
96 const LatencyInfo::LatencyComponent& gpu_swap_begin_component, | 111 const LatencyInfo::LatencyComponent& gpu_swap_begin_component, |
97 const LatencyInfo::LatencyComponent& gpu_swap_end_component, | 112 const LatencyInfo::LatencyComponent& gpu_swap_end_component, |
98 int64_t latency_component_id, | 113 int64_t latency_component_id, |
99 const LatencyInfo& latency, | 114 const LatencyInfo& latency, |
100 bool is_running_navigation_hint_task) { | 115 bool is_running_navigation_hint_task) { |
101 DCHECK(!latency.coalesced()); | 116 DCHECK(!latency.coalesced()); |
102 if (latency.coalesced()) | 117 if (latency.coalesced()) |
103 return; | 118 return; |
104 | 119 |
105 DCHECK(!gpu_swap_begin_component.event_time.is_null()); | 120 DCHECK(!gpu_swap_begin_component.event_time.is_null()); |
106 DCHECK(!gpu_swap_end_component.event_time.is_null()); | 121 DCHECK(!gpu_swap_end_component.event_time.is_null()); |
107 LatencyInfo::LatencyComponent original_component; | 122 LatencyInfo::LatencyComponent original_component; |
123 bool is_first_scroll = false; | |
108 if (latency.FindLatency( | 124 if (latency.FindLatency( |
109 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 125 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
110 latency_component_id, &original_component)) { | 126 latency_component_id, &original_component)) { |
111 // This UMA metric tracks the time between the final frame swap for the | 127 is_first_scroll = true; |
112 // first scroll event in a sequence and the original timestamp of that | |
113 // scroll event's underlying touch event. | |
114 for (size_t i = 0; i < original_component.event_count; i++) { | |
115 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | |
116 "Event.Latency.TouchToFirstScrollUpdateSwapBegin", | |
117 original_component, gpu_swap_begin_component); | |
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 } | |
130 } else if (!latency.FindLatency( | 128 } else if (!latency.FindLatency( |
131 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 129 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
132 latency_component_id, &original_component)) { | 130 latency_component_id, &original_component)) { |
133 return; | 131 return; |
134 } | 132 } |
135 | 133 |
136 // This UMA metric tracks the time from when the original touch event is | 134 // This UMA metric tracks the time from when the original touch event is |
137 // created to when the scroll gesture results in final frame swap. | 135 // created to when the scroll gesture results in final frame swap. |
138 for (size_t i = 0; i < original_component.event_count; i++) { | 136 for (size_t i = 0; i < original_component.event_count; i++) { |
139 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | 137 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
140 "Event.Latency.TouchToScrollUpdateSwapBegin", original_component, | 138 is_first_scroll, "Event.Latency.TouchTo%sScrollUpdateSwapBegin", |
141 gpu_swap_begin_component); | 139 original_component, gpu_swap_begin_component); |
142 } | 140 } |
143 // TODO(horo): IsRunningNavigationHintTask UMAs are only for | 141 // TODO(horo): IsRunningNavigationHintTask UMAs are only for |
144 // SpeculativeLaunchServiceWorker experimentation. So remove this UMA when | 142 // SpeculativeLaunchServiceWorker experimentation. So remove this UMA when |
145 // the experimentation finished (crbug.com/638827). | 143 // the experimentation finished (crbug.com/638827). |
146 if (is_running_navigation_hint_task) { | 144 if (is_running_navigation_hint_task) { |
147 for (size_t i = 0; i < original_component.event_count; i++) { | 145 for (size_t i = 0; i < original_component.event_count; i++) { |
148 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | 146 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
149 "Event.Latency.TouchToScrollUpdateSwapBegin_" | 147 is_first_scroll, |
148 "Event.Latency.TouchTo%sScrollUpdateSwapBegin_" | |
150 "IsRunningNavigationHintTask", | 149 "IsRunningNavigationHintTask", |
151 original_component, gpu_swap_begin_component); | 150 original_component, gpu_swap_begin_component); |
152 } | 151 } |
153 } | 152 } |
154 | 153 |
155 // TODO(miletus): Add validation for making sure the following components | |
156 // are present and their event times are legit. | |
157 LatencyInfo::LatencyComponent rendering_scheduled_component; | 154 LatencyInfo::LatencyComponent rendering_scheduled_component; |
158 bool rendering_scheduled_on_main = latency.FindLatency( | 155 bool rendering_scheduled_on_main = latency.FindLatency( |
159 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, | 156 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, |
160 0, &rendering_scheduled_component); | 157 0, &rendering_scheduled_component); |
161 | 158 |
162 if (!rendering_scheduled_on_main) { | 159 if (!rendering_scheduled_on_main) { |
163 if (!latency.FindLatency( | 160 if (!latency.FindLatency( |
164 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, | 161 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, |
165 0, &rendering_scheduled_component)) | 162 &rendering_scheduled_component)) { |
166 return; | 163 return; |
164 } | |
167 } | 165 } |
168 | 166 |
169 if (rendering_scheduled_on_main) { | 167 if (rendering_scheduled_on_main) { |
170 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | 168 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
171 "Event.Latency.ScrollUpdate.TouchToHandled_Main", | 169 is_first_scroll, "Event.Latency.%sScrollUpdate.TouchToHandled_Main", |
172 original_component, rendering_scheduled_component); | 170 original_component, rendering_scheduled_component); |
173 } else { | 171 } else { |
174 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | 172 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
175 "Event.Latency.ScrollUpdate.TouchToHandled_Impl", | 173 is_first_scroll, "Event.Latency.%sScrollUpdate.TouchToHandled_Impl", |
176 original_component, rendering_scheduled_component); | 174 original_component, rendering_scheduled_component); |
177 } | 175 } |
178 | 176 |
179 LatencyInfo::LatencyComponent renderer_swap_component; | 177 LatencyInfo::LatencyComponent renderer_swap_component; |
180 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, | 178 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, |
181 0, &renderer_swap_component)) | 179 &renderer_swap_component)) { |
182 return; | 180 return; |
181 } | |
183 | 182 |
184 if (rendering_scheduled_on_main) { | 183 if (rendering_scheduled_on_main) { |
185 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | 184 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
186 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Main", | 185 is_first_scroll, |
186 "Event.Latency.%sScrollUpdate.HandledToRendererSwap_Main", | |
tdresser
2016/09/08 15:17:25
Passing these format strings around is a bit scary
| |
187 rendering_scheduled_component, renderer_swap_component); | 187 rendering_scheduled_component, renderer_swap_component); |
188 } else { | 188 } else { |
189 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | 189 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
190 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Impl", | 190 is_first_scroll, |
191 "Event.Latency.%sScrollUpdate.HandledToRendererSwap_Impl", | |
191 rendering_scheduled_component, renderer_swap_component); | 192 rendering_scheduled_component, renderer_swap_component); |
192 } | 193 } |
193 | 194 |
194 LatencyInfo::LatencyComponent browser_received_swap_component; | 195 LatencyInfo::LatencyComponent browser_received_swap_component; |
195 if (!latency.FindLatency( | 196 if (!latency.FindLatency( |
196 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, | 197 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, |
197 0, &browser_received_swap_component)) | 198 &browser_received_swap_component)) { |
198 return; | 199 return; |
200 } | |
199 | 201 |
200 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( | 202 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( |
201 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", | 203 is_first_scroll, |
204 "Event.Latency.%sScrollUpdate.RendererSwapToBrowserNotified", | |
202 renderer_swap_component, browser_received_swap_component); | 205 renderer_swap_component, browser_received_swap_component); |
203 | 206 |
204 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | 207 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
205 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", | 208 is_first_scroll, |
209 "Event.Latency.%sScrollUpdate.BrowserNotifiedToBeforeGpuSwap", | |
206 browser_received_swap_component, gpu_swap_begin_component); | 210 browser_received_swap_component, gpu_swap_begin_component); |
207 | 211 |
208 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", | 212 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( |
209 gpu_swap_begin_component, | 213 is_first_scroll, "Event.Latency.%sScrollUpdate.GpuSwap", |
210 gpu_swap_end_component); | 214 gpu_swap_begin_component, gpu_swap_end_component); |
211 } | 215 } |
212 | 216 |
213 // LatencyComponents generated in the renderer must have component IDs | 217 // LatencyComponents generated in the renderer must have component IDs |
214 // provided to them by the browser process. This function adds the correct | 218 // provided to them by the browser process. This function adds the correct |
215 // component ID where necessary. | 219 // component ID where necessary. |
216 void AddLatencyInfoComponentIds(LatencyInfo* latency, | 220 void AddLatencyInfoComponentIds(LatencyInfo* latency, |
217 int64_t latency_component_id) { | 221 int64_t latency_component_id) { |
218 std::vector<std::pair<ui::LatencyComponentType, int64_t>> new_components_key; | 222 std::vector<std::pair<ui::LatencyComponentType, int64_t>> new_components_key; |
219 std::vector<LatencyInfo::LatencyComponent> new_components_value; | 223 std::vector<LatencyInfo::LatencyComponent> new_components_value; |
220 for (const auto& lc : latency->latency_components()) { | 224 for (const auto& lc : latency->latency_components()) { |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 latency_component_id_, nullptr)) { | 596 latency_component_id_, nullptr)) { |
593 return; | 597 return; |
594 } | 598 } |
595 | 599 |
596 ComputeScrollLatencyHistograms(gpu_swap_begin_component, | 600 ComputeScrollLatencyHistograms(gpu_swap_begin_component, |
597 gpu_swap_end_component, latency_component_id_, | 601 gpu_swap_end_component, latency_component_id_, |
598 latency, is_running_navigation_hint_task); | 602 latency, is_running_navigation_hint_task); |
599 } | 603 } |
600 | 604 |
601 } // namespace content | 605 } // namespace content |
OLD | NEW |