Chromium Code Reviews| Index: content/browser/renderer_host/input/render_widget_host_latency_tracker.cc |
| diff --git a/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc b/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc |
| index 38079dd70bed3528ba88d0c77f972efa1bb37f80..a6ca8653e427ea6cd502c1b249abaaccce2983f7 100644 |
| --- a/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc |
| +++ b/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc |
| @@ -92,6 +92,33 @@ void UpdateLatencyCoordinates(const WebInputEvent& event, |
| (end.event_time - start.event_time).InMicroseconds(), \ |
| 1, 50000, 50) |
| +// Check valid timing for start and end latency components. |
| +#define CONFIRM_VALID_TIMING(start, end) \ |
| + DCHECK(!start.first_event_time.is_null()); \ |
| + DCHECK(!end.last_event_time.is_null()); \ |
| + DCHECK_GE(end.last_event_time, start.first_event_time); |
| + |
| +// Touch/wheel to scroll latency that is mostly under 1 second. |
| +#define UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY(name, start, end) \ |
| + CONFIRM_VALID_TIMING(start, end) \ |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| + name, (end.last_event_time - start.first_event_time).InMicroseconds(), \ |
| + 1, 1000000, 100) |
| + |
| +// Long touch/wheel scroll latency component that is mostly under 200ms. |
| +#define UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(name, start, end) \ |
| + CONFIRM_VALID_TIMING(start, end) \ |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| + name, (end.last_event_time - start.first_event_time).InMicroseconds(), \ |
| + 1000, 200000, 50) |
| + |
| +// Short touch/wheel scroll latency component that is mostly under 50ms. |
| +#define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2(name, start, end) \ |
| + CONFIRM_VALID_TIMING(start, end) \ |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| + name, (end.last_event_time - start.first_event_time).InMicroseconds(), \ |
| + 1, 50000, 50) |
| + |
| void ComputeScrollLatencyHistograms( |
| const LatencyInfo::LatencyComponent& gpu_swap_begin_component, |
| const LatencyInfo::LatencyComponent& gpu_swap_end_component, |
| @@ -210,6 +237,98 @@ void ComputeScrollLatencyHistograms( |
| gpu_swap_end_component); |
| } |
| +void ComputeTouchAndWheelScrollLatencyHistograms( |
| + const ui::LatencyInfo::LatencyComponent& gpu_swap_begin_component, |
| + const ui::LatencyInfo::LatencyComponent& gpu_swap_end_component, |
| + int64_t latency_component_id, |
| + const ui::LatencyInfo& latency, |
| + const std::string event_type_name) { |
| + DCHECK(!latency.coalesced()); |
| + if (latency.coalesced()) |
| + return; |
| + |
| + LatencyInfo::LatencyComponent original_component; |
| + if (latency.FindLatency( |
| + ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| + latency_component_id, &original_component)) { |
| + // This UMA metric tracks the time between the final frame swap for the |
| + // first scroll event in a sequence and the original timestamp of that |
| + // scroll event's underlying touch/wheel event. |
| + UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY( |
| + "Event.Latency." + event_type_name + ".ToFirstScrollUpdateSwapBegin", |
| + original_component, gpu_swap_begin_component); |
| + } else if (!latency.FindLatency( |
| + ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| + latency_component_id, &original_component)) { |
| + return; |
| + } |
| + |
| + // This UMA metric tracks the time from when the original touch event is |
| + // created to when the scroll gesture results in final frame swap. |
| + if (event_type_name == "Touch") { |
| + UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY( |
| + "Event.Latency." + event_type_name + ".ToScrollUpdateSwapBegin", |
|
tdresser
2016/09/23 14:28:38
We want to exclude the first GSU from this metric.
sahel
2016/09/23 20:48:23
Done.
|
| + original_component, gpu_swap_begin_component); |
| + } |
| + LatencyInfo::LatencyComponent rendering_scheduled_component; |
| + bool rendering_scheduled_on_main = latency.FindLatency( |
| + ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, |
| + &rendering_scheduled_component); |
| + if (!rendering_scheduled_on_main) { |
| + if (!latency.FindLatency( |
| + ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, |
| + &rendering_scheduled_component)) |
| + return; |
| + } |
| + |
| + if (rendering_scheduled_on_main) { |
| + UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2( |
| + "Event.Latency.ScrollUpdate." + event_type_name + ".ToHandled_Main", |
| + original_component, rendering_scheduled_component); |
| + } else { |
| + UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2( |
| + "Event.Latency.ScrollUpdate." + event_type_name + ".ToHandled_Impl", |
| + original_component, rendering_scheduled_component); |
| + } |
| + |
| + LatencyInfo::LatencyComponent renderer_swap_component; |
| + if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, |
| + &renderer_swap_component)) |
| + return; |
| + |
| + if (rendering_scheduled_on_main) { |
| + UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2( |
| + "Event.Latency.ScrollUpdate." + event_type_name + |
| + ".HandledToRendererSwap_Main", |
| + rendering_scheduled_component, renderer_swap_component); |
| + } else { |
| + UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2( |
| + "Event.Latency.ScrollUpdate." + event_type_name + |
| + ".HandledToRendererSwap_Impl", |
| + rendering_scheduled_component, renderer_swap_component); |
| + } |
| + |
| + LatencyInfo::LatencyComponent browser_received_swap_component; |
| + if (!latency.FindLatency( |
| + ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, |
| + &browser_received_swap_component)) |
| + return; |
| + |
| + UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2( |
| + "Event.Latency.ScrollUpdate." + event_type_name + |
| + ".RendererSwapToBrowserNotified", |
| + renderer_swap_component, browser_received_swap_component); |
| + |
| + UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2( |
| + "Event.Latency.ScrollUpdate." + event_type_name + |
| + ".BrowserNotifiedToBeforeGpuSwap", |
| + browser_received_swap_component, gpu_swap_begin_component); |
| + |
| + UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2( |
| + "Event.Latency.ScrollUpdate." + event_type_name + ".GpuSwap", |
| + gpu_swap_begin_component, gpu_swap_end_component); |
| +} |
| + |
| // LatencyComponents generated in the renderer must have component IDs |
| // provided to them by the browser process. This function adds the correct |
| // component ID where necessary. |
| @@ -555,15 +674,6 @@ void RenderWidgetHostLatencyTracker::OnSwapCompositorFrame( |
| void RenderWidgetHostLatencyTracker::OnFrameSwapped( |
| const LatencyInfo& latency, |
| bool is_running_navigation_hint_task) { |
| - // Don't report frame latency on wheel events. Previously they were only |
| - // reported on touch metrics and we need to be consistent across reporting |
| - // metrics. |
| - LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component; |
| - if (latency.FindLatency( |
| - ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, |
| - &mouse_wheel_scroll_update_component)) { |
| - return; |
| - } |
| LatencyInfo::LatencyComponent gpu_swap_end_component; |
| if (!latency.FindLatency( |
| @@ -593,9 +703,28 @@ void RenderWidgetHostLatencyTracker::OnFrameSwapped( |
| return; |
| } |
| - ComputeScrollLatencyHistograms(gpu_swap_begin_component, |
| - gpu_swap_end_component, latency_component_id_, |
| - latency, is_running_navigation_hint_task); |
| + // Don't report frame latency on wheel events. Previously they were only |
| + // reported on touch metrics and we need to be consistent across reporting |
| + // metrics. |
|
tdresser
2016/09/23 14:28:38
We should update this comment, as we are now repor
sahel
2016/09/23 20:48:23
Done.
|
| + LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component; |
| + if (!latency.FindLatency( |
| + ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, |
| + &mouse_wheel_scroll_update_component)) { |
| + ComputeScrollLatencyHistograms( |
|
tdresser
2016/09/23 14:28:38
Might be worth mentioning in a comment here that w
sahel
2016/09/23 20:48:23
Done.
|
| + gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_, |
| + latency, is_running_navigation_hint_task); |
| + } |
| + |
| + ui::SourceEventType source_event_type = latency.source_event_type(); |
| + if (source_event_type != ui::SourceEventType::WHEEL && |
| + source_event_type != ui::SourceEventType::TOUCH) { |
| + return; |
| + } |
| + |
| + ComputeTouchAndWheelScrollLatencyHistograms( |
| + gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_, |
| + latency, |
| + source_event_type == ui::SourceEventType::WHEEL ? "Wheel" : "Touch"); |
| } |
| } // namespace content |