| 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_functions.h" |
| 10 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 11 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 12 #include "components/rappor/public/rappor_utils.h" | 13 #include "components/rappor/public/rappor_utils.h" |
| 13 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 14 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 14 #include "content/public/browser/content_browser_client.h" | 15 #include "content/public/browser/content_browser_client.h" |
| 15 #include "content/public/common/content_client.h" | 16 #include "content/public/common/content_client.h" |
| 16 #include "ui/events/blink/web_input_event_traits.h" | 17 #include "ui/events/blink/web_input_event_traits.h" |
| 17 | 18 |
| 18 using blink::WebGestureEvent; | 19 using blink::WebGestureEvent; |
| 19 using blink::WebInputEvent; | 20 using blink::WebInputEvent; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 latency, device_scale_factor); | 69 latency, device_scale_factor); |
| 69 } else if (WebInputEvent::isTouchEventType(event.type())) { | 70 } else if (WebInputEvent::isTouchEventType(event.type())) { |
| 70 UpdateLatencyCoordinatesImpl(static_cast<const WebTouchEvent&>(event), | 71 UpdateLatencyCoordinatesImpl(static_cast<const WebTouchEvent&>(event), |
| 71 latency, device_scale_factor); | 72 latency, device_scale_factor); |
| 72 } else if (event.type() == WebInputEvent::MouseWheel) { | 73 } else if (event.type() == WebInputEvent::MouseWheel) { |
| 73 UpdateLatencyCoordinatesImpl(static_cast<const WebMouseWheelEvent&>(event), | 74 UpdateLatencyCoordinatesImpl(static_cast<const WebMouseWheelEvent&>(event), |
| 74 latency, device_scale_factor); | 75 latency, device_scale_factor); |
| 75 } | 76 } |
| 76 } | 77 } |
| 77 | 78 |
| 78 // Touch to scroll latency that is mostly under 1 second. | |
| 79 #define UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY(name, start, end) \ | |
| 80 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | |
| 81 name, (end.event_time - start.event_time).InMicroseconds(), 1, 1000000, \ | |
| 82 100) | |
| 83 | |
| 84 // Long scroll latency component that is mostly under 200ms. | |
| 85 #define UMA_HISTOGRAM_SCROLL_LATENCY_LONG(name, start, end) \ | |
| 86 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | |
| 87 name, \ | |
| 88 (end.event_time - start.event_time).InMicroseconds(), \ | |
| 89 1000, 200000, 50) | |
| 90 | |
| 91 // Short scroll latency component that is mostly under 50ms. | |
| 92 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT(name, start, end) \ | |
| 93 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | |
| 94 name, \ | |
| 95 (end.event_time - start.event_time).InMicroseconds(), \ | |
| 96 1, 50000, 50) | |
| 97 | |
| 98 // Check valid timing for start and end latency components. | 79 // Check valid timing for start and end latency components. |
| 99 #define CONFIRM_VALID_TIMING(start, end) \ | 80 #define CONFIRM_VALID_TIMING(start, end) \ |
| 100 DCHECK(!start.first_event_time.is_null()); \ | 81 DCHECK(!start.first_event_time.is_null()); \ |
| 101 DCHECK(!end.last_event_time.is_null()); \ | 82 DCHECK(!end.last_event_time.is_null()); \ |
| 102 DCHECK_GE(end.last_event_time, start.first_event_time); | 83 DCHECK_GE(end.last_event_time, start.first_event_time); |
| 103 | 84 |
| 85 // Long scroll latency component that is mostly under 200ms. |
| 86 #define UMA_HISTOGRAM_SCROLL_LATENCY_LONG(name, start, end) \ |
| 87 CONFIRM_VALID_TIMING(start, end); \ |
| 88 UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 89 name, (end.event_time - start.event_time).InMicroseconds(), 1000, \ |
| 90 200000, 50) |
| 91 |
| 92 // Short scroll latency component that is mostly under 50ms. |
| 93 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT(name, start, end) \ |
| 94 CONFIRM_VALID_TIMING(start, end); \ |
| 95 UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 96 name, (end.event_time - start.event_time).InMicroseconds(), 1, 50000, \ |
| 97 50) |
| 98 |
| 99 // Event latency that is mostly under 1 second. We should only use 100 buckets |
| 100 // when needed. |
| 101 #define UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS(name, start, \ |
| 102 end) \ |
| 103 CONFIRM_VALID_TIMING(start, end) \ |
| 104 base::UmaHistogramCustomCounts( \ |
| 105 name, (end.last_event_time - start.first_event_time).InMicroseconds(), \ |
| 106 1, 1000000, 100); |
| 107 |
| 108 #define UMA_HISTOGRAM_INPUT_LATENCY_MILLISECONDS(name, start, end) \ |
| 109 CONFIRM_VALID_TIMING(start, end) \ |
| 110 base::UmaHistogramCustomCounts( \ |
| 111 name, (end.last_event_time - start.first_event_time).InMilliseconds(), \ |
| 112 1, 1000, 50); |
| 113 |
| 104 // Touch/wheel to scroll latency using Rappor. | 114 // Touch/wheel to scroll latency using Rappor. |
| 105 #define RAPPOR_TOUCH_WHEEL_TO_SCROLL_LATENCY(delegate, name, start, end) \ | 115 #define RAPPOR_TOUCH_WHEEL_TO_SCROLL_LATENCY(delegate, name, start, end) \ |
| 106 CONFIRM_VALID_TIMING(start, end) \ | 116 CONFIRM_VALID_TIMING(start, end) \ |
| 107 rappor::RapporService* rappor_service = \ | 117 rappor::RapporService* rappor_service = \ |
| 108 GetContentClient()->browser()->GetRapporService(); \ | 118 GetContentClient()->browser()->GetRapporService(); \ |
| 109 if (rappor_service && delegate) { \ | 119 if (rappor_service && delegate) { \ |
| 110 std::unique_ptr<rappor::Sample> sample = \ | 120 std::unique_ptr<rappor::Sample> sample = \ |
| 111 rappor_service->CreateSample(rappor::UMA_RAPPOR_TYPE); \ | 121 rappor_service->CreateSample(rappor::UMA_RAPPOR_TYPE); \ |
| 112 delegate->AddDomainInfoToRapporSample(sample.get()); \ | 122 delegate->AddDomainInfoToRapporSample(sample.get()); \ |
| 113 sample->SetUInt64Field( \ | 123 sample->SetUInt64Field( \ |
| 114 "Latency", \ | 124 "Latency", \ |
| 115 (end.last_event_time - start.first_event_time).InMicroseconds(), \ | 125 (end.last_event_time - start.first_event_time).InMicroseconds(), \ |
| 116 rappor::NO_NOISE); \ | 126 rappor::NO_NOISE); \ |
| 117 rappor_service->RecordSample(name, std::move(sample)); \ | 127 rappor_service->RecordSample(name, std::move(sample)); \ |
| 118 } | 128 } |
| 119 | 129 |
| 120 // Touch/wheel to scroll latency that is mostly under 1 second. | |
| 121 #define UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY(name, start, end) \ | |
| 122 CONFIRM_VALID_TIMING(start, end) \ | |
| 123 base::Histogram::FactoryGet(name, 1, 1000000, 100, \ | |
| 124 base::HistogramBase::kUmaTargetedHistogramFlag) \ | |
| 125 ->Add((end.last_event_time - start.first_event_time).InMicroseconds()); | |
| 126 | |
| 127 // Long touch/wheel scroll latency component that is mostly under 200ms. | 130 // Long touch/wheel scroll latency component that is mostly under 200ms. |
| 128 #define UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(name, start, end) \ | 131 #define UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(name, start, end) \ |
| 129 CONFIRM_VALID_TIMING(start, end) \ | 132 CONFIRM_VALID_TIMING(start, end) \ |
| 130 base::Histogram::FactoryGet(name, 1000, 200000, 50, \ | 133 base::Histogram::FactoryGet(name, 1000, 200000, 50, \ |
| 131 base::HistogramBase::kUmaTargetedHistogramFlag) \ | 134 base::HistogramBase::kUmaTargetedHistogramFlag) \ |
| 132 ->Add((end.last_event_time - start.first_event_time).InMicroseconds()); | 135 ->Add((end.last_event_time - start.first_event_time).InMicroseconds()); |
| 133 | 136 |
| 134 // Short touch/wheel scroll latency component that is mostly under 50ms. | 137 // Short touch/wheel scroll latency component that is mostly under 50ms. |
| 135 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2(name, start, end) \ | 138 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2(name, start, end) \ |
| 136 CONFIRM_VALID_TIMING(start, end) \ | 139 CONFIRM_VALID_TIMING(start, end) \ |
| 137 base::Histogram::FactoryGet(name, 1, 50000, 50, \ | 140 base::Histogram::FactoryGet(name, 1, 50000, 50, \ |
| 138 base::HistogramBase::kUmaTargetedHistogramFlag) \ | 141 base::HistogramBase::kUmaTargetedHistogramFlag) \ |
| 139 ->Add((end.last_event_time - start.first_event_time).InMicroseconds()); | 142 ->Add((end.last_event_time - start.first_event_time).InMicroseconds()); |
| 140 | 143 |
| 144 std::string LatencySourceEventTypeToInputModalityString( |
| 145 ui::SourceEventType type) { |
| 146 switch (type) { |
| 147 case ui::SourceEventType::WHEEL: |
| 148 return "Wheel"; |
| 149 case ui::SourceEventType::TOUCH: |
| 150 return "Touch"; |
| 151 default: |
| 152 return ""; |
| 153 } |
| 154 } |
| 155 |
| 156 std::string WebInputEventTypeToInputModalityString(WebInputEvent::Type type) { |
| 157 if (type == blink::WebInputEvent::MouseWheel) { |
| 158 return "Wheel"; |
| 159 } else if (WebInputEvent::isKeyboardEventType(type)) { |
| 160 return "Key"; |
| 161 } else if (WebInputEvent::isMouseEventType(type)) { |
| 162 return "Mouse"; |
| 163 } else if (WebInputEvent::isTouchEventType(type)) { |
| 164 return "Touch"; |
| 165 } |
| 166 return ""; |
| 167 } |
| 168 |
| 141 void ComputeScrollLatencyHistograms( | 169 void ComputeScrollLatencyHistograms( |
| 142 const LatencyInfo::LatencyComponent& gpu_swap_begin_component, | 170 const LatencyInfo::LatencyComponent& gpu_swap_begin_component, |
| 143 const LatencyInfo::LatencyComponent& gpu_swap_end_component, | 171 const LatencyInfo::LatencyComponent& gpu_swap_end_component, |
| 144 int64_t latency_component_id, | 172 int64_t latency_component_id, |
| 145 const LatencyInfo& latency, | 173 const LatencyInfo& latency, |
| 146 bool is_running_navigation_hint_task) { | 174 bool is_running_navigation_hint_task) { |
| 147 DCHECK(!latency.coalesced()); | 175 DCHECK(!latency.coalesced()); |
| 148 if (latency.coalesced()) | 176 if (latency.coalesced()) |
| 149 return; | 177 return; |
| 150 | 178 |
| 151 DCHECK(!gpu_swap_begin_component.event_time.is_null()); | 179 DCHECK(!gpu_swap_begin_component.event_time.is_null()); |
| 152 DCHECK(!gpu_swap_end_component.event_time.is_null()); | 180 DCHECK(!gpu_swap_end_component.event_time.is_null()); |
| 153 LatencyInfo::LatencyComponent original_component; | 181 LatencyInfo::LatencyComponent original_component; |
| 154 if (latency.FindLatency( | 182 if (latency.FindLatency( |
| 155 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 183 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| 156 latency_component_id, &original_component)) { | 184 latency_component_id, &original_component)) { |
| 157 // This UMA metric tracks the time between the final frame swap for the | 185 // This UMA metric tracks the time between the final frame swap for the |
| 158 // first scroll event in a sequence and the original timestamp of that | 186 // first scroll event in a sequence and the original timestamp of that |
| 159 // scroll event's underlying touch event. | 187 // scroll event's underlying touch event. |
| 160 for (size_t i = 0; i < original_component.event_count; i++) { | 188 for (size_t i = 0; i < original_component.event_count; i++) { |
| 161 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | 189 UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS( |
| 162 "Event.Latency.TouchToFirstScrollUpdateSwapBegin", | 190 "Event.Latency.TouchToFirstScrollUpdateSwapBegin", |
| 163 original_component, gpu_swap_begin_component); | 191 original_component, gpu_swap_begin_component); |
| 164 } | 192 } |
| 165 // TODO(horo): IsRunningNavigationHintTask UMAs are only for | 193 // TODO(horo): IsRunningNavigationHintTask UMAs are only for |
| 166 // SpeculativeLaunchServiceWorker experimentation. So remove this UMA when | 194 // SpeculativeLaunchServiceWorker experimentation. So remove this UMA when |
| 167 // the experimentation finished (crbug.com/638827). | 195 // the experimentation finished (crbug.com/638827). |
| 168 if (is_running_navigation_hint_task) { | 196 if (is_running_navigation_hint_task) { |
| 169 for (size_t i = 0; i < original_component.event_count; i++) { | 197 for (size_t i = 0; i < original_component.event_count; i++) { |
| 170 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | 198 UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS( |
| 171 "Event.Latency.TouchToFirstScrollUpdateSwapBegin_" | 199 "Event.Latency.TouchToFirstScrollUpdateSwapBegin_" |
| 172 "IsRunningNavigationHintTask", | 200 "IsRunningNavigationHintTask", |
| 173 original_component, gpu_swap_begin_component); | 201 original_component, gpu_swap_begin_component); |
| 174 } | 202 } |
| 175 } | 203 } |
| 176 } else if (!latency.FindLatency( | 204 } else if (!latency.FindLatency( |
| 177 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 205 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| 178 latency_component_id, &original_component)) { | 206 latency_component_id, &original_component)) { |
| 179 return; | 207 return; |
| 180 } | 208 } |
| 181 | 209 |
| 182 // This UMA metric tracks the time from when the original touch event is | 210 // This UMA metric tracks the time from when the original touch event is |
| 183 // created to when the scroll gesture results in final frame swap. | 211 // created to when the scroll gesture results in final frame swap. |
| 184 for (size_t i = 0; i < original_component.event_count; i++) { | 212 for (size_t i = 0; i < original_component.event_count; i++) { |
| 185 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | 213 UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS( |
| 186 "Event.Latency.TouchToScrollUpdateSwapBegin", original_component, | 214 "Event.Latency.TouchToScrollUpdateSwapBegin", original_component, |
| 187 gpu_swap_begin_component); | 215 gpu_swap_begin_component); |
| 188 } | 216 } |
| 189 // TODO(horo): IsRunningNavigationHintTask UMAs are only for | 217 // TODO(horo): IsRunningNavigationHintTask UMAs are only for |
| 190 // SpeculativeLaunchServiceWorker experimentation. So remove this UMA when | 218 // SpeculativeLaunchServiceWorker experimentation. So remove this UMA when |
| 191 // the experimentation finished (crbug.com/638827). | 219 // the experimentation finished (crbug.com/638827). |
| 192 if (is_running_navigation_hint_task) { | 220 if (is_running_navigation_hint_task) { |
| 193 for (size_t i = 0; i < original_component.event_count; i++) { | 221 for (size_t i = 0; i < original_component.event_count; i++) { |
| 194 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | 222 UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS( |
| 195 "Event.Latency.TouchToScrollUpdateSwapBegin_" | 223 "Event.Latency.TouchToScrollUpdateSwapBegin_" |
| 196 "IsRunningNavigationHintTask", | 224 "IsRunningNavigationHintTask", |
| 197 original_component, gpu_swap_begin_component); | 225 original_component, gpu_swap_begin_component); |
| 198 } | 226 } |
| 199 } | 227 } |
| 200 | 228 |
| 201 // TODO(miletus): Add validation for making sure the following components | 229 // TODO(miletus): Add validation for making sure the following components |
| 202 // are present and their event times are legit. | 230 // are present and their event times are legit. |
| 203 LatencyInfo::LatencyComponent rendering_scheduled_component; | 231 LatencyInfo::LatencyComponent rendering_scheduled_component; |
| 204 bool rendering_scheduled_on_main = latency.FindLatency( | 232 bool rendering_scheduled_on_main = latency.FindLatency( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", | 282 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", |
| 255 gpu_swap_begin_component, | 283 gpu_swap_begin_component, |
| 256 gpu_swap_end_component); | 284 gpu_swap_end_component); |
| 257 } | 285 } |
| 258 | 286 |
| 259 void ComputeTouchAndWheelScrollLatencyHistograms( | 287 void ComputeTouchAndWheelScrollLatencyHistograms( |
| 260 RenderWidgetHostDelegate* render_widget_host_delegate, | 288 RenderWidgetHostDelegate* render_widget_host_delegate, |
| 261 const ui::LatencyInfo::LatencyComponent& gpu_swap_begin_component, | 289 const ui::LatencyInfo::LatencyComponent& gpu_swap_begin_component, |
| 262 const ui::LatencyInfo::LatencyComponent& gpu_swap_end_component, | 290 const ui::LatencyInfo::LatencyComponent& gpu_swap_end_component, |
| 263 int64_t latency_component_id, | 291 int64_t latency_component_id, |
| 264 const ui::LatencyInfo& latency, | 292 const ui::LatencyInfo& latency) { |
| 265 const std::string event_type_name) { | |
| 266 DCHECK(!latency.coalesced()); | 293 DCHECK(!latency.coalesced()); |
| 267 DCHECK(event_type_name == "Touch" || event_type_name == "Wheel"); | |
| 268 if (latency.coalesced()) | 294 if (latency.coalesced()) |
| 269 return; | 295 return; |
| 270 | 296 |
| 271 LatencyInfo::LatencyComponent original_component; | 297 LatencyInfo::LatencyComponent original_component; |
| 272 std::string scroll_name = "ScrollUpdate"; | 298 std::string scroll_name = "ScrollUpdate"; |
| 299 |
| 300 const std::string input_modality = |
| 301 LatencySourceEventTypeToInputModalityString(latency.source_event_type()); |
| 302 |
| 273 if (latency.FindLatency( | 303 if (latency.FindLatency( |
| 274 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 304 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| 275 latency_component_id, &original_component)) { | 305 latency_component_id, &original_component)) { |
| 276 scroll_name = "ScrollBegin"; | 306 scroll_name = "ScrollBegin"; |
| 277 // This UMA metric tracks the time between the final frame swap for the | 307 // This UMA metric tracks the time between the final frame swap for the |
| 278 // first scroll event in a sequence and the original timestamp of that | 308 // first scroll event in a sequence and the original timestamp of that |
| 279 // scroll event's underlying touch/wheel event. | 309 // scroll event's underlying touch/wheel event. |
| 280 | 310 UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS( |
| 281 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY( | 311 "Event.Latency.ScrollBegin." + input_modality + |
| 282 "Event.Latency.ScrollBegin." + event_type_name + | |
| 283 ".TimeToScrollUpdateSwapBegin2", | 312 ".TimeToScrollUpdateSwapBegin2", |
| 284 original_component, gpu_swap_begin_component); | 313 original_component, gpu_swap_begin_component); |
| 285 | 314 |
| 286 RAPPOR_TOUCH_WHEEL_TO_SCROLL_LATENCY( | 315 RAPPOR_TOUCH_WHEEL_TO_SCROLL_LATENCY( |
| 287 render_widget_host_delegate, | 316 render_widget_host_delegate, |
| 288 "Event.Latency.ScrollBegin." + event_type_name + | 317 "Event.Latency.ScrollBegin." + input_modality + |
| 289 ".TimeToScrollUpdateSwapBegin2", | 318 ".TimeToScrollUpdateSwapBegin2", |
| 290 original_component, gpu_swap_begin_component); | 319 original_component, gpu_swap_begin_component); |
| 291 | 320 |
| 292 // TODO(lanwei): Will remove them when M56 is stable, see | 321 // TODO(lanwei): Will remove them when M56 is stable, see |
| 293 // https://crbug.com/669618. | 322 // https://crbug.com/669618. |
| 294 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY( | 323 UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS( |
| 295 "Event.Latency.ScrollUpdate." + event_type_name + | 324 "Event.Latency.ScrollUpdate." + input_modality + |
| 296 ".TimeToFirstScrollUpdateSwapBegin2", | 325 ".TimeToFirstScrollUpdateSwapBegin2", |
| 297 original_component, gpu_swap_begin_component); | 326 original_component, gpu_swap_begin_component); |
| 298 } else if (latency.FindLatency( | 327 } else if (latency.FindLatency( |
| 299 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 328 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| 300 latency_component_id, &original_component)) { | 329 latency_component_id, &original_component)) { |
| 301 // This UMA metric tracks the time from when the original touch event is | 330 // This UMA metric tracks the time from when the original touch event is |
| 302 // created to when the scroll gesture results in final frame swap. | 331 // created to when the scroll gesture results in final frame swap. |
| 303 // First scroll events are excluded from this metric. | 332 // First scroll events are excluded from this metric. |
| 304 if (event_type_name == "Touch") { | 333 if (input_modality == "Touch") { |
| 305 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY( | 334 UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS( |
| 306 "Event.Latency.ScrollUpdate." + event_type_name + | 335 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2", |
| 307 ".TimeToScrollUpdateSwapBegin2", | |
| 308 original_component, gpu_swap_begin_component); | 336 original_component, gpu_swap_begin_component); |
| 309 | 337 |
| 310 RAPPOR_TOUCH_WHEEL_TO_SCROLL_LATENCY( | 338 RAPPOR_TOUCH_WHEEL_TO_SCROLL_LATENCY( |
| 311 render_widget_host_delegate, | 339 render_widget_host_delegate, |
| 312 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2", | 340 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2", |
| 313 original_component, gpu_swap_begin_component); | 341 original_component, gpu_swap_begin_component); |
| 314 } | 342 } |
| 315 } else { | 343 } else { |
| 316 // No original component found. | 344 // No original component found. |
| 317 return; | 345 return; |
| 318 } | 346 } |
| 319 | 347 |
| 320 LatencyInfo::LatencyComponent rendering_scheduled_component; | 348 LatencyInfo::LatencyComponent rendering_scheduled_component; |
| 321 bool rendering_scheduled_on_main = latency.FindLatency( | 349 bool rendering_scheduled_on_main = latency.FindLatency( |
| 322 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, | 350 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, |
| 323 &rendering_scheduled_component); | 351 &rendering_scheduled_component); |
| 324 if (!rendering_scheduled_on_main) { | 352 if (!rendering_scheduled_on_main) { |
| 325 if (!latency.FindLatency( | 353 if (!latency.FindLatency( |
| 326 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, | 354 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, |
| 327 &rendering_scheduled_component)) | 355 &rendering_scheduled_component)) |
| 328 return; | 356 return; |
| 329 } | 357 } |
| 330 | 358 |
| 331 const std::string thread_name = rendering_scheduled_on_main ? "Main" : "Impl"; | 359 const std::string thread_name = rendering_scheduled_on_main ? "Main" : "Impl"; |
| 332 | 360 |
| 333 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2( | 361 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2( |
| 334 "Event.Latency." + scroll_name + "." + event_type_name + | 362 "Event.Latency." + scroll_name + "." + input_modality + |
| 335 ".TimeToHandled2_" + thread_name, | 363 ".TimeToHandled2_" + thread_name, |
| 336 original_component, rendering_scheduled_component); | 364 original_component, rendering_scheduled_component); |
| 337 | 365 |
| 338 LatencyInfo::LatencyComponent renderer_swap_component; | 366 LatencyInfo::LatencyComponent renderer_swap_component; |
| 339 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, | 367 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, |
| 340 &renderer_swap_component)) | 368 &renderer_swap_component)) |
| 341 return; | 369 return; |
| 342 | 370 |
| 343 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2( | 371 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2( |
| 344 "Event.Latency." + scroll_name + "." + event_type_name + | 372 "Event.Latency." + scroll_name + "." + input_modality + |
| 345 ".HandledToRendererSwap2_" + thread_name, | 373 ".HandledToRendererSwap2_" + thread_name, |
| 346 rendering_scheduled_component, renderer_swap_component); | 374 rendering_scheduled_component, renderer_swap_component); |
| 347 | 375 |
| 348 LatencyInfo::LatencyComponent browser_received_swap_component; | 376 LatencyInfo::LatencyComponent browser_received_swap_component; |
| 349 if (!latency.FindLatency( | 377 if (!latency.FindLatency( |
| 350 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, | 378 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, |
| 351 &browser_received_swap_component)) | 379 &browser_received_swap_component)) |
| 352 return; | 380 return; |
| 353 | 381 |
| 354 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2( | 382 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2( |
| 355 "Event.Latency." + scroll_name + "." + event_type_name + | 383 "Event.Latency." + scroll_name + "." + input_modality + |
| 356 ".RendererSwapToBrowserNotified2", | 384 ".RendererSwapToBrowserNotified2", |
| 357 renderer_swap_component, browser_received_swap_component); | 385 renderer_swap_component, browser_received_swap_component); |
| 358 | 386 |
| 359 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2( | 387 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2( |
| 360 "Event.Latency." + scroll_name + "." + event_type_name + | 388 "Event.Latency." + scroll_name + "." + input_modality + |
| 361 ".BrowserNotifiedToBeforeGpuSwap2", | 389 ".BrowserNotifiedToBeforeGpuSwap2", |
| 362 browser_received_swap_component, gpu_swap_begin_component); | 390 browser_received_swap_component, gpu_swap_begin_component); |
| 363 | 391 |
| 364 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2( | 392 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2( |
| 365 "Event.Latency." + scroll_name + "." + event_type_name + ".GpuSwap2", | 393 "Event.Latency." + scroll_name + "." + input_modality + ".GpuSwap2", |
| 366 gpu_swap_begin_component, gpu_swap_end_component); | 394 gpu_swap_begin_component, gpu_swap_end_component); |
| 367 } | 395 } |
| 368 // LatencyComponents generated in the renderer must have component IDs | 396 // LatencyComponents generated in the renderer must have component IDs |
| 369 // provided to them by the browser process. This function adds the correct | 397 // provided to them by the browser process. This function adds the correct |
| 370 // component ID where necessary. | 398 // component ID where necessary. |
| 371 void AddLatencyInfoComponentIds(LatencyInfo* latency, | 399 void AddLatencyInfoComponentIds(LatencyInfo* latency, |
| 372 int64_t latency_component_id) { | 400 int64_t latency_component_id) { |
| 373 std::vector<std::pair<ui::LatencyComponentType, int64_t>> new_components_key; | 401 std::vector<std::pair<ui::LatencyComponentType, int64_t>> new_components_key; |
| 374 std::vector<LatencyInfo::LatencyComponent> new_components_value; | 402 std::vector<LatencyInfo::LatencyComponent> new_components_value; |
| 375 for (const auto& lc : latency->latency_components()) { | 403 for (const auto& lc : latency->latency_components()) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 DCHECK_EQ(0, latency_component_id_); | 443 DCHECK_EQ(0, latency_component_id_); |
| 416 last_event_id_ = static_cast<int64_t>(process_id) << 32; | 444 last_event_id_ = static_cast<int64_t>(process_id) << 32; |
| 417 latency_component_id_ = routing_id | last_event_id_; | 445 latency_component_id_ = routing_id | last_event_id_; |
| 418 } | 446 } |
| 419 | 447 |
| 420 void RenderWidgetHostLatencyTracker::ComputeInputLatencyHistograms( | 448 void RenderWidgetHostLatencyTracker::ComputeInputLatencyHistograms( |
| 421 WebInputEvent::Type type, | 449 WebInputEvent::Type type, |
| 422 int64_t latency_component_id, | 450 int64_t latency_component_id, |
| 423 const LatencyInfo& latency, | 451 const LatencyInfo& latency, |
| 424 InputEventAckState ack_result) { | 452 InputEventAckState ack_result) { |
| 453 // If this event was coalesced into another event, ignore it, as the event it |
| 454 // was coalesced into will reflect the full latency. |
| 425 if (latency.coalesced()) | 455 if (latency.coalesced()) |
| 426 return; | 456 return; |
| 427 | 457 |
| 458 if (type != blink::WebInputEvent::MouseWheel && |
| 459 !WebInputEvent::isTouchEventType(type)) { |
| 460 return; |
| 461 } |
| 462 |
| 428 LatencyInfo::LatencyComponent rwh_component; | 463 LatencyInfo::LatencyComponent rwh_component; |
| 429 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 464 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| 430 latency_component_id, &rwh_component)) { | 465 latency_component_id, &rwh_component)) { |
| 431 return; | 466 return; |
| 432 } | 467 } |
| 433 DCHECK_EQ(rwh_component.event_count, 1u); | 468 DCHECK_EQ(rwh_component.event_count, 1u); |
| 434 | 469 |
| 435 LatencyInfo::LatencyComponent ui_component; | 470 LatencyInfo::LatencyComponent ui_component; |
| 436 if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, | 471 if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, |
| 437 &ui_component)) { | 472 &ui_component)) { |
| 438 DCHECK_EQ(ui_component.event_count, 1u); | 473 DCHECK_EQ(ui_component.event_count, 1u); |
| 439 base::TimeDelta ui_delta = | 474 base::TimeDelta ui_delta = |
| 440 rwh_component.event_time - ui_component.event_time; | 475 rwh_component.last_event_time - ui_component.first_event_time; |
| 441 | 476 |
| 442 if (type == blink::WebInputEvent::MouseWheel) { | 477 if (type == blink::WebInputEvent::MouseWheel) { |
| 443 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.WheelUI", | 478 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.WheelUI", |
| 444 ui_delta.InMicroseconds(), 1, 20000, 100); | 479 ui_delta.InMicroseconds(), 1, 20000, 100); |
| 445 | |
| 446 } else { | 480 } else { |
| 447 DCHECK(WebInputEvent::isTouchEventType(type)); | 481 DCHECK(WebInputEvent::isTouchEventType(type)); |
| 448 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.TouchUI", | 482 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.TouchUI", |
| 449 ui_delta.InMicroseconds(), 1, 20000, 100); | 483 ui_delta.InMicroseconds(), 1, 20000, 100); |
| 450 } | 484 } |
| 451 } | 485 } |
| 452 | 486 |
| 453 // Both tap and scroll gestures depend on the disposition of the touch start | 487 // Both tap and scroll gestures depend on the disposition of the touch start |
| 454 // and the current touch. For touch start, touch_start_default_prevented_ == | 488 // and the current touch. For touch start, touch_start_default_prevented_ == |
| 455 // (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED). | 489 // (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED). |
| 456 bool action_prevented = touch_start_default_prevented_ || | 490 bool action_prevented = touch_start_default_prevented_ || |
| 457 ack_result == INPUT_EVENT_ACK_STATE_CONSUMED; | 491 ack_result == INPUT_EVENT_ACK_STATE_CONSUMED; |
| 458 | 492 |
| 493 std::string event_name = WebInputEvent::GetName(type); |
| 494 |
| 495 std::string default_action_status = |
| 496 action_prevented ? "DefaultPrevented" : "DefaultAllowed"; |
| 497 |
| 459 LatencyInfo::LatencyComponent main_component; | 498 LatencyInfo::LatencyComponent main_component; |
| 460 if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, | 499 if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, |
| 461 &main_component)) { | 500 &main_component)) { |
| 462 DCHECK_EQ(main_component.event_count, 1u); | 501 DCHECK_EQ(main_component.event_count, 1u); |
| 463 base::TimeDelta queueing_delta = | |
| 464 main_component.event_time - rwh_component.event_time; | |
| 465 | |
| 466 if (!multi_finger_gesture_) { | 502 if (!multi_finger_gesture_) { |
| 467 if (action_prevented) { | 503 UMA_HISTOGRAM_INPUT_LATENCY_MILLISECONDS( |
| 468 switch (type) { | 504 "Event.Latency.QueueingTime." + event_name + default_action_status, |
| 469 case WebInputEvent::TouchStart: | 505 rwh_component, main_component); |
| 470 UMA_HISTOGRAM_TIMES( | |
| 471 "Event.Latency.QueueingTime.TouchStartDefaultPrevented", | |
| 472 queueing_delta); | |
| 473 break; | |
| 474 case WebInputEvent::TouchMove: | |
| 475 UMA_HISTOGRAM_TIMES( | |
| 476 "Event.Latency.QueueingTime.TouchMoveDefaultPrevented", | |
| 477 queueing_delta); | |
| 478 break; | |
| 479 case WebInputEvent::TouchEnd: | |
| 480 UMA_HISTOGRAM_TIMES( | |
| 481 "Event.Latency.QueueingTime.TouchEndDefaultPrevented", | |
| 482 queueing_delta); | |
| 483 break; | |
| 484 default: | |
| 485 break; | |
| 486 } | |
| 487 } else { | |
| 488 switch (type) { | |
| 489 case WebInputEvent::TouchStart: | |
| 490 UMA_HISTOGRAM_TIMES( | |
| 491 "Event.Latency.QueueingTime.TouchStartDefaultAllowed", | |
| 492 queueing_delta); | |
| 493 break; | |
| 494 case WebInputEvent::TouchMove: | |
| 495 UMA_HISTOGRAM_TIMES( | |
| 496 "Event.Latency.QueueingTime.TouchMoveDefaultAllowed", | |
| 497 queueing_delta); | |
| 498 break; | |
| 499 case WebInputEvent::TouchEnd: | |
| 500 UMA_HISTOGRAM_TIMES( | |
| 501 "Event.Latency.QueueingTime.TouchEndDefaultAllowed", | |
| 502 queueing_delta); | |
| 503 break; | |
| 504 default: | |
| 505 break; | |
| 506 } | |
| 507 } | |
| 508 } | 506 } |
| 509 } | 507 } |
| 510 | 508 |
| 511 LatencyInfo::LatencyComponent acked_component; | 509 LatencyInfo::LatencyComponent acked_component; |
| 512 if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, | 510 if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, |
| 513 &acked_component)) { | 511 &acked_component)) { |
| 514 DCHECK_EQ(acked_component.event_count, 1u); | 512 DCHECK_EQ(acked_component.event_count, 1u); |
| 515 base::TimeDelta acked_delta = | 513 if (!multi_finger_gesture_ && |
| 516 acked_component.event_time - rwh_component.event_time; | 514 main_component.event_time != base::TimeTicks()) { |
| 517 if (type == blink::WebInputEvent::MouseWheel) { | 515 UMA_HISTOGRAM_INPUT_LATENCY_MILLISECONDS( |
| 518 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.WheelAcked", | 516 "Event.Latency.BlockingTime." + event_name + default_action_status, |
| 519 acked_delta.InMicroseconds(), 1, 1000000, | 517 main_component, acked_component); |
| 520 100); | |
| 521 } else { | |
| 522 DCHECK(WebInputEvent::isTouchEventType(type)); | |
| 523 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.TouchAcked", | |
| 524 acked_delta.InMicroseconds(), 1, 1000000, | |
| 525 100); | |
| 526 } | 518 } |
| 527 | 519 |
| 528 if (!multi_finger_gesture_ && | 520 std::string input_modality = WebInputEventTypeToInputModalityString(type); |
| 529 main_component.event_time != base::TimeTicks()) { | 521 if (input_modality != "") { |
| 530 base::TimeDelta blocking_delta; | 522 UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS( |
| 531 blocking_delta = acked_component.event_time - main_component.event_time; | 523 "Event.Latency.Browser." + input_modality + "Acked", rwh_component, |
| 532 | 524 acked_component); |
| 533 if (action_prevented) { | |
| 534 switch (type) { | |
| 535 case WebInputEvent::TouchStart: | |
| 536 UMA_HISTOGRAM_TIMES( | |
| 537 "Event.Latency.BlockingTime.TouchStartDefaultPrevented", | |
| 538 blocking_delta); | |
| 539 break; | |
| 540 case WebInputEvent::TouchMove: | |
| 541 UMA_HISTOGRAM_TIMES( | |
| 542 "Event.Latency.BlockingTime.TouchMoveDefaultPrevented", | |
| 543 blocking_delta); | |
| 544 break; | |
| 545 case WebInputEvent::TouchEnd: | |
| 546 UMA_HISTOGRAM_TIMES( | |
| 547 "Event.Latency.BlockingTime.TouchEndDefaultPrevented", | |
| 548 blocking_delta); | |
| 549 break; | |
| 550 default: | |
| 551 break; | |
| 552 } | |
| 553 } else { | |
| 554 switch (type) { | |
| 555 case WebInputEvent::TouchStart: | |
| 556 UMA_HISTOGRAM_TIMES( | |
| 557 "Event.Latency.BlockingTime.TouchStartDefaultAllowed", | |
| 558 blocking_delta); | |
| 559 break; | |
| 560 case WebInputEvent::TouchMove: | |
| 561 UMA_HISTOGRAM_TIMES( | |
| 562 "Event.Latency.BlockingTime.TouchMoveDefaultAllowed", | |
| 563 blocking_delta); | |
| 564 break; | |
| 565 case WebInputEvent::TouchEnd: | |
| 566 UMA_HISTOGRAM_TIMES( | |
| 567 "Event.Latency.BlockingTime.TouchEndDefaultAllowed", | |
| 568 blocking_delta); | |
| 569 break; | |
| 570 default: | |
| 571 break; | |
| 572 } | |
| 573 } | |
| 574 } | 525 } |
| 575 } | 526 } |
| 576 } | 527 } |
| 577 | 528 |
| 578 void RenderWidgetHostLatencyTracker::OnInputEvent( | 529 void RenderWidgetHostLatencyTracker::OnInputEvent( |
| 579 const blink::WebInputEvent& event, | 530 const blink::WebInputEvent& event, |
| 580 LatencyInfo* latency) { | 531 LatencyInfo* latency) { |
| 581 DCHECK(latency); | 532 DCHECK(latency); |
| 582 if (latency->FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 533 if (latency->FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| 583 latency_component_id_, NULL)) { | 534 latency_component_id_, NULL)) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 | 583 |
| 633 has_seen_first_gesture_scroll_update_ = true; | 584 has_seen_first_gesture_scroll_update_ = true; |
| 634 } | 585 } |
| 635 } | 586 } |
| 636 | 587 |
| 637 void RenderWidgetHostLatencyTracker::OnInputEventAck( | 588 void RenderWidgetHostLatencyTracker::OnInputEventAck( |
| 638 const blink::WebInputEvent& event, | 589 const blink::WebInputEvent& event, |
| 639 LatencyInfo* latency, InputEventAckState ack_result) { | 590 LatencyInfo* latency, InputEventAckState ack_result) { |
| 640 DCHECK(latency); | 591 DCHECK(latency); |
| 641 | 592 |
| 642 // Latency ends when it is acked but does not cause render scheduling. | 593 // Latency ends if an event is acked but does not cause render scheduling. |
| 643 bool rendering_scheduled = latency->FindLatency( | 594 bool rendering_scheduled = latency->FindLatency( |
| 644 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, nullptr); | 595 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, nullptr); |
| 645 rendering_scheduled |= latency->FindLatency( | 596 rendering_scheduled |= latency->FindLatency( |
| 646 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, nullptr); | 597 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, nullptr); |
| 647 | 598 |
| 648 if (WebInputEvent::isGestureEventType(event.type())) { | |
| 649 if (!rendering_scheduled) { | |
| 650 latency->AddLatencyNumber( | |
| 651 ui::INPUT_EVENT_LATENCY_TERMINATED_GESTURE_COMPONENT, 0, 0); | |
| 652 // TODO(jdduke): Consider exposing histograms for gesture event types. | |
| 653 } | |
| 654 return; | |
| 655 } | |
| 656 | |
| 657 if (WebInputEvent::isTouchEventType(event.type())) { | 599 if (WebInputEvent::isTouchEventType(event.type())) { |
| 658 const WebTouchEvent& touch_event = | 600 const WebTouchEvent& touch_event = |
| 659 *static_cast<const WebTouchEvent*>(&event); | 601 *static_cast<const WebTouchEvent*>(&event); |
| 660 if (event.type() == WebInputEvent::TouchStart) { | 602 if (event.type() == WebInputEvent::TouchStart) { |
| 661 DCHECK(touch_event.touchesLength >= 1); | 603 DCHECK(touch_event.touchesLength >= 1); |
| 662 multi_finger_gesture_ = touch_event.touchesLength != 1; | 604 multi_finger_gesture_ = touch_event.touchesLength != 1; |
| 663 touch_start_default_prevented_ = | 605 touch_start_default_prevented_ = |
| 664 ack_result == INPUT_EVENT_ACK_STATE_CONSUMED; | 606 ack_result == INPUT_EVENT_ACK_STATE_CONSUMED; |
| 665 } | 607 } |
| 666 | |
| 667 latency->AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0); | |
| 668 | |
| 669 if (!rendering_scheduled) { | |
| 670 latency->AddLatencyNumber( | |
| 671 ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, 0); | |
| 672 } | |
| 673 ComputeInputLatencyHistograms(event.type(), latency_component_id_, *latency, | |
| 674 ack_result); | |
| 675 return; | |
| 676 } | 608 } |
| 677 | 609 |
| 678 if (event.type() == WebInputEvent::MouseWheel) { | 610 latency->AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0); |
| 679 latency->AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0); | 611 // If this event couldn't have caused a gesture event, and it didn't trigger |
| 680 if (!rendering_scheduled) { | 612 // rendering, we're done processing it. |
| 681 latency->AddLatencyNumber( | 613 if (!rendering_scheduled) { |
| 682 ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_WHEEL_COMPONENT, 0, 0); | 614 latency->AddLatencyNumber( |
| 683 } | 615 ui::INPUT_EVENT_LATENCY_TERMINATED_NO_SWAP_COMPONENT, 0, 0); |
| 684 ComputeInputLatencyHistograms(event.type(), latency_component_id_, *latency, | |
| 685 ack_result); | |
| 686 return; | |
| 687 } | 616 } |
| 688 | 617 |
| 689 if (WebInputEvent::isMouseEventType(event.type()) && !rendering_scheduled) { | 618 ComputeInputLatencyHistograms(event.type(), latency_component_id_, *latency, |
| 690 latency->AddLatencyNumber( | 619 ack_result); |
| 691 ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_COMPONENT, 0, 0); | |
| 692 return; | |
| 693 } | |
| 694 | |
| 695 if (WebInputEvent::isKeyboardEventType(event.type()) && | |
| 696 !rendering_scheduled) { | |
| 697 latency->AddLatencyNumber( | |
| 698 ui::INPUT_EVENT_LATENCY_TERMINATED_KEYBOARD_COMPONENT, 0, 0); | |
| 699 return; | |
| 700 } | |
| 701 } | 620 } |
| 702 | 621 |
| 703 void RenderWidgetHostLatencyTracker::OnSwapCompositorFrame( | 622 void RenderWidgetHostLatencyTracker::OnSwapCompositorFrame( |
| 704 std::vector<LatencyInfo>* latencies) { | 623 std::vector<LatencyInfo>* latencies) { |
| 705 DCHECK(latencies); | 624 DCHECK(latencies); |
| 706 for (LatencyInfo& latency : *latencies) { | 625 for (LatencyInfo& latency : *latencies) { |
| 707 AddLatencyInfoComponentIds(&latency, latency_component_id_); | 626 AddLatencyInfoComponentIds(&latency, latency_component_id_); |
| 708 latency.AddLatencyNumber( | 627 latency.AddLatencyNumber( |
| 709 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); | 628 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); |
| 710 } | 629 } |
| 711 } | 630 } |
| 712 | 631 |
| 713 void RenderWidgetHostLatencyTracker::OnFrameSwapped( | 632 void RenderWidgetHostLatencyTracker::OnFrameSwapped( |
| 714 const LatencyInfo& latency, | 633 const LatencyInfo& latency, |
| 715 bool is_running_navigation_hint_task) { | 634 bool is_running_navigation_hint_task) { |
| 716 | |
| 717 LatencyInfo::LatencyComponent gpu_swap_end_component; | 635 LatencyInfo::LatencyComponent gpu_swap_end_component; |
| 718 if (!latency.FindLatency( | 636 if (!latency.FindLatency( |
| 719 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, | 637 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, |
| 720 &gpu_swap_end_component)) { | 638 &gpu_swap_end_component)) { |
| 721 return; | 639 return; |
| 722 } | 640 } |
| 723 | 641 |
| 724 LatencyInfo::LatencyComponent gpu_swap_begin_component; | 642 LatencyInfo::LatencyComponent gpu_swap_begin_component; |
| 725 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, | 643 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, |
| 726 &gpu_swap_begin_component)) { | 644 &gpu_swap_begin_component)) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 740 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 658 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| 741 latency_component_id_, nullptr)) { | 659 latency_component_id_, nullptr)) { |
| 742 return; | 660 return; |
| 743 } | 661 } |
| 744 | 662 |
| 745 ui::SourceEventType source_event_type = latency.source_event_type(); | 663 ui::SourceEventType source_event_type = latency.source_event_type(); |
| 746 if (source_event_type == ui::SourceEventType::WHEEL || | 664 if (source_event_type == ui::SourceEventType::WHEEL || |
| 747 source_event_type == ui::SourceEventType::TOUCH) { | 665 source_event_type == ui::SourceEventType::TOUCH) { |
| 748 ComputeTouchAndWheelScrollLatencyHistograms( | 666 ComputeTouchAndWheelScrollLatencyHistograms( |
| 749 render_widget_host_delegate_, gpu_swap_begin_component, | 667 render_widget_host_delegate_, gpu_swap_begin_component, |
| 750 gpu_swap_end_component, latency_component_id_, latency, | 668 gpu_swap_end_component, latency_component_id_, latency); |
| 751 source_event_type == ui::SourceEventType::WHEEL ? "Wheel" : "Touch"); | |
| 752 } | 669 } |
| 753 | 670 |
| 754 // Compute the old scroll update latency metrics. They are exclusively | 671 // Compute the old scroll update latency metrics. They are exclusively |
| 755 // calculated for touch scrolls, and will be deprecated on M56. | 672 // calculated for touch scrolls, and will be deprecated on M56. |
| 756 // (https://crbug.com/649754) | 673 // (https://crbug.com/649754) |
| 757 LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component; | 674 LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component; |
| 758 if (!latency.FindLatency( | 675 if (!latency.FindLatency( |
| 759 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, | 676 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, |
| 760 &mouse_wheel_scroll_update_component)) { | 677 &mouse_wheel_scroll_update_component)) { |
| 761 ComputeScrollLatencyHistograms( | 678 ComputeScrollLatencyHistograms( |
| 762 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_, | 679 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_, |
| 763 latency, is_running_navigation_hint_task); | 680 latency, is_running_navigation_hint_task); |
| 764 } | 681 } |
| 765 } | 682 } |
| 766 | 683 |
| 767 void RenderWidgetHostLatencyTracker::SetDelegate( | 684 void RenderWidgetHostLatencyTracker::SetDelegate( |
| 768 RenderWidgetHostDelegate* delegate) { | 685 RenderWidgetHostDelegate* delegate) { |
| 769 render_widget_host_delegate_ = delegate; | 686 render_widget_host_delegate_ = delegate; |
| 770 } | 687 } |
| 771 | 688 |
| 772 } // namespace content | 689 } // namespace content |
| OLD | NEW |