diff options
author | Jared Duke <jdduke@chromium.org> | 2015-01-20 08:12:58 -0800 |
---|---|---|
committer | Jared Duke <jdduke@chromium.org> | 2015-01-20 16:14:31 +0000 |
commit | f7ca804fb226366e5547153a38660d574636b4df (patch) | |
tree | 44b0d8f27ef57cb63cd46c568726e74f9a1d67ac | |
parent | 8e9c02da125a76c1fcc6171e11c9863cbf709d07 (diff) | |
download | chromium_src-f7ca804fb226366e5547153a38660d574636b4df.zip chromium_src-f7ca804fb226366e5547153a38660d574636b4df.tar.gz chromium_src-f7ca804fb226366e5547153a38660d574636b4df.tar.bz2 |
Add UMA for TouchToFirstScrollUpdateSwap
TouchToScrollUpdateSwap is currently tracked in UMA. While this is
useful for gauging the typical response time for each event in a scroll
sequence, it is insufficient to indicate the intial scroll response
time. Add a TouchToFirstScrollUpdateSwap which measures the time between
touch event creation for the first GestureScrollUpdate in a sequence and
the frame swap time caused by that first scroll event.
Also remove INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT as it is no
longer used on Aura.
BUG=436965
Review URL: https://codereview.chromium.org/827963005
Cr-Commit-Position: refs/heads/master@{#311928}
(cherry picked from commit bf3a626647d8813df8491b8c4babc4442940dadc)
Review URL: https://codereview.chromium.org/861783002
Cr-Commit-Position: refs/branch-heads/2272@{#58}
Cr-Branched-From: 827a380cfdb31aa54c8d56e63ce2c3fd8c3ba4d4-refs/heads/master@{#310958}
7 files changed, 123 insertions, 40 deletions
diff --git a/content/browser/renderer_host/input/input_router_impl_perftest.cc b/content/browser/renderer_host/input/input_router_impl_perftest.cc index ad83264..017bd617 100644 --- a/content/browser/renderer_host/input/input_router_impl_perftest.cc +++ b/content/browser/renderer_host/input/input_router_impl_perftest.cc @@ -261,10 +261,8 @@ class InputRouterImplPerfTest : public testing::Test { ui::LatencyInfo latency; latency.AddLatencyNumber( ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 1, 0); - latency.AddLatencyNumber( - ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT, - 1, - NextLatencyID()); + latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1, + NextLatencyID()); return latency; } diff --git a/content/browser/renderer_host/render_widget_host_latency_tracker.cc b/content/browser/renderer_host/render_widget_host_latency_tracker.cc index d47562b..2d738c4 100644 --- a/content/browser/renderer_host/render_widget_host_latency_tracker.cc +++ b/content/browser/renderer_host/render_widget_host_latency_tracker.cc @@ -135,6 +135,44 @@ void ComputeInputLatencyHistograms(WebInputEvent::Type type, } } +void ComputeScrollLatencyHistograms( + const LatencyInfo::LatencyComponent& swap_component, + int64 latency_component_id, + const ui::LatencyInfo& latency) { + DCHECK(!swap_component.event_time.is_null()); + LatencyInfo::LatencyComponent first_original_component, original_component; + if (latency.FindLatency( + ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, + latency_component_id, &first_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 event. + for (size_t i = 0; i < first_original_component.event_count; i++) { + UMA_HISTOGRAM_CUSTOM_COUNTS( + "Event.Latency.TouchToFirstScrollUpdateSwap", + (swap_component.event_time - first_original_component.event_time) + .InMicroseconds(), + 1, 1000000, 100); + } + original_component = first_original_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 (averaged if there are multiple) to when the scroll gesture + // results in final frame swap. + for (size_t i = 0; i < original_component.event_count; i++) { + UMA_HISTOGRAM_CUSTOM_COUNTS( + "Event.Latency.TouchToScrollUpdateSwap", + (swap_component.event_time - original_component.event_time) + .InMicroseconds(), + 1, 1000000, 100); + } +} + // 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. @@ -169,6 +207,7 @@ RenderWidgetHostLatencyTracker::RenderWidgetHostLatencyTracker() : last_event_id_(0), latency_component_id_(0), device_scale_factor_(1), + has_seent_first_gesture_scroll_update_(false), browser_composite_latency_history_(kBrowserCompositeLatencyHistorySize) { } @@ -197,11 +236,9 @@ void RenderWidgetHostLatencyTracker::OnInputEvent( latency->TraceEventType(WebInputEventTraits::GetName(event.type)); UpdateLatencyCoordinates(event, device_scale_factor_, latency); - if (event.type == blink::WebInputEvent::GestureScrollUpdate) { - latency->AddLatencyNumber( - ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT, - latency_component_id_, ++last_event_id_); - + if (event.type == blink::WebInputEvent::GestureScrollBegin) { + has_seent_first_gesture_scroll_update_ = false; + } else if (event.type == blink::WebInputEvent::GestureScrollUpdate) { // Make a copy of the INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT with a // different name INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT. // So we can track the latency specifically for scroll update events. @@ -209,10 +246,14 @@ void RenderWidgetHostLatencyTracker::OnInputEvent( if (latency->FindLatency(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, &original_component)) { latency->AddLatencyNumberWithTimestamp( - ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, + has_seent_first_gesture_scroll_update_ + ? ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT + : ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, latency_component_id_, original_component.sequence_number, original_component.event_time, original_component.event_count); } + + has_seent_first_gesture_scroll_update_ = true; } } @@ -295,23 +336,8 @@ void RenderWidgetHostLatencyTracker::OnFrameSwapped( return; } - LatencyInfo::LatencyComponent original_component; - if (latency.FindLatency( - ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, - latency_component_id_, &original_component)) { - // This UMA metric tracks the time from when the original touch event is - // created (averaged if there are multiple) to when the scroll gesture - // results in final frame swap. - for (size_t i = 0; i < original_component.event_count; i++) { - UMA_HISTOGRAM_CUSTOM_COUNTS( - "Event.Latency.TouchToScrollUpdateSwap", - (swap_component.event_time - original_component.event_time) - .InMicroseconds(), - 1, - 1000000, - 100); - } - } + ComputeScrollLatencyHistograms(swap_component, latency_component_id_, + latency); ui::LatencyInfo::LatencyComponent gpu_swap_component; if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, diff --git a/content/browser/renderer_host/render_widget_host_latency_tracker.h b/content/browser/renderer_host/render_widget_host_latency_tracker.h index 08c580c..beb972e 100644 --- a/content/browser/renderer_host/render_widget_host_latency_tracker.h +++ b/content/browser/renderer_host/render_widget_host_latency_tracker.h @@ -67,6 +67,7 @@ class CONTENT_EXPORT RenderWidgetHostLatencyTracker { int64 last_event_id_; int64 latency_component_id_; float device_scale_factor_; + bool has_seent_first_gesture_scroll_update_; cc::RollingTimeDeltaHistory browser_composite_latency_history_; DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostLatencyTracker); diff --git a/content/browser/renderer_host/render_widget_host_latency_tracker_unittest.cc b/content/browser/renderer_host/render_widget_host_latency_tracker_unittest.cc index 80e3137..1c5b7b8 100644 --- a/content/browser/renderer_host/render_widget_host_latency_tracker_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_latency_tracker_unittest.cc @@ -29,9 +29,6 @@ TEST(RenderWidgetHostLatencyTrackerTest, Basic) { EXPECT_TRUE( scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, tracker.latency_component_id(), nullptr)); - EXPECT_TRUE(scroll_latency.FindLatency( - ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT, - tracker.latency_component_id(), nullptr)); EXPECT_EQ(1U, scroll_latency.input_coordinates_size); } @@ -158,4 +155,57 @@ TEST(RenderWidgetHostLatencyTrackerTest, InputCoordinatesPopulated) { } } +TEST(RenderWidgetHostLatencyTrackerTest, ScrollLatency) { + RenderWidgetHostLatencyTracker tracker; + tracker.Initialize(kTestRoutingId, kTestProcessId); + + auto scroll_begin = SyntheticWebGestureEventBuilder::BuildScrollBegin(5, -5); + ui::LatencyInfo scroll_latency; + scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, + 0); + tracker.OnInputEvent(scroll_begin, &scroll_latency); + EXPECT_TRUE( + scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, + tracker.latency_component_id(), nullptr)); + EXPECT_EQ(2U, scroll_latency.latency_components.size()); + + // The first GestureScrollUpdate should be provided with + // INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT. + auto first_scroll_update = SyntheticWebGestureEventBuilder::BuildScrollUpdate( + 5.f, -5.f, 0, blink::WebGestureDeviceTouchscreen); + scroll_latency = ui::LatencyInfo(); + scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, + 0); + tracker.OnInputEvent(first_scroll_update, &scroll_latency); + EXPECT_TRUE( + scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, + tracker.latency_component_id(), nullptr)); + EXPECT_TRUE(scroll_latency.FindLatency( + ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, + tracker.latency_component_id(), nullptr)); + EXPECT_FALSE(scroll_latency.FindLatency( + ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, + tracker.latency_component_id(), nullptr)); + EXPECT_EQ(3U, scroll_latency.latency_components.size()); + + // Subseqeunt GestureScrollUpdates should be provided with + // INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT. + auto scroll_update = SyntheticWebGestureEventBuilder::BuildScrollUpdate( + -5.f, 5.f, 0, blink::WebGestureDeviceTouchscreen); + scroll_latency = ui::LatencyInfo(); + scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, + 0); + tracker.OnInputEvent(scroll_update, &scroll_latency); + EXPECT_TRUE( + scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, + tracker.latency_component_id(), nullptr)); + EXPECT_FALSE(scroll_latency.FindLatency( + ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, + tracker.latency_component_id(), nullptr)); + EXPECT_TRUE(scroll_latency.FindLatency( + ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, + tracker.latency_component_id(), nullptr)); + EXPECT_EQ(3U, scroll_latency.latency_components.size()); +} + } // namespace content diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 52a08e1..003024b 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -7222,11 +7222,23 @@ Therefore, the affected-histogram name has to have at least one dot in it. </summary> </histogram> +<histogram name="Event.Latency.TouchToFirstScrollUpdateSwap" + units="microseconds"> + <owner>rbyers@chromium.org</owner> + <summary> + Time between initial creation of a touch event and the frame swap caused by + by the generated ScrollUpdate gesture event if that ScrollUpdate is the + first such in a given scroll gesture event sequence. If no swap was induced + by the event, no recording is made. + </summary> +</histogram> + <histogram name="Event.Latency.TouchToScrollUpdateSwap" units="microseconds"> <owner>rbyers@chromium.org</owner> <summary> - Time between initial creation of touch event and the resulting frame from - ScrollUpdate is swapped. + Time between initial creation of a touch event and the frame swap caused by + by the generated ScrollUpdate gesture event. If no swap was induced by the + event, no recording is made. </summary> </histogram> diff --git a/ui/events/latency_info.cc b/ui/events/latency_info.cc index 5940539..6050d26 100644 --- a/ui/events/latency_info.cc +++ b/ui/events/latency_info.cc @@ -20,8 +20,8 @@ const char* GetComponentName(ui::LatencyComponentType type) { CASE_TYPE(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT); CASE_TYPE(INPUT_EVENT_LATENCY_BEGIN_PLUGIN_COMPONENT); CASE_TYPE(INPUT_EVENT_LATENCY_BEGIN_SCROLL_UPDATE_MAIN_COMPONENT); - CASE_TYPE(INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT); CASE_TYPE(INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT); + CASE_TYPE(INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT); CASE_TYPE(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); CASE_TYPE(INPUT_EVENT_LATENCY_UI_COMPONENT); CASE_TYPE(INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT); diff --git a/ui/events/latency_info.h b/ui/events/latency_info.h index 732c1cb..c3a52b8 100644 --- a/ui/events/latency_info.h +++ b/ui/events/latency_info.h @@ -25,15 +25,11 @@ enum LatencyComponentType { // Timestamp when a scroll update for the main thread is begun. INPUT_EVENT_LATENCY_BEGIN_SCROLL_UPDATE_MAIN_COMPONENT, // ---------------------------NORMAL COMPONENT------------------------------- - // Timestamp when the scroll update gesture event is sent from RWH to - // renderer. In Aura, touch event's LatencyInfo is carried over to the gesture - // event. So gesture event's INPUT_EVENT_LATENCY_RWH_COMPONENT is the - // timestamp when its original touch events is sent from RWH to renderer. - // In non-aura platform, INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT - // is the same as INPUT_EVENT_LATENCY_RWH_COMPONENT. - INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT, // The original timestamp of the touch event which converts to scroll update. INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, + // The original timestamp of the touch event which converts to the *first* + // scroll update in a scroll gesture sequence. + INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, // Original timestamp for input event (e.g. timestamp from kernel). INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, // Timestamp when the UI event is created. |