summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdduke <jdduke@chromium.org>2015-05-07 11:33:44 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-07 18:35:15 +0000
commit89b12a7f9295845aebae43d037e8de65b9ac00e5 (patch)
treeb0e2a885ddf38c7b8dc8ffba7196fc1618d38326
parentf804405f8b61fb40c3ce1e2cf7efc464e7f7f1cf (diff)
downloadchromium_src-89b12a7f9295845aebae43d037e8de65b9ac00e5.zip
chromium_src-89b12a7f9295845aebae43d037e8de65b9ac00e5.tar.gz
chromium_src-89b12a7f9295845aebae43d037e8de65b9ac00e5.tar.bz2
Provide simple fling bookkeeping for telemetry
Have the InputRouter track active renderer flings, rather than all flings as was tried in the original change that was reverted in crrev.com/1113143002. Also re-enable the smoothness.fling.simple_mobile_sites telemetry benchmark, and ensure WebView DidStopFlinging notifications are consistent with other platforms. BUG=483037 Review URL: https://codereview.chromium.org/1125713004 Cr-Commit-Position: refs/heads/master@{#328801}
-rw-r--r--content/browser/android/in_process/synchronous_compositor_impl.cc10
-rw-r--r--content/browser/renderer_host/input/input_router_impl.cc19
-rw-r--r--content/browser/renderer_host/input/input_router_impl.h5
-rw-r--r--content/browser/renderer_host/input/input_router_impl_unittest.cc41
-rw-r--r--tools/perf/benchmarks/smoothness.py2
5 files changed, 69 insertions, 8 deletions
diff --git a/content/browser/android/in_process/synchronous_compositor_impl.cc b/content/browser/android/in_process/synchronous_compositor_impl.cc
index 823a897..24232ae 100644
--- a/content/browser/android/in_process/synchronous_compositor_impl.cc
+++ b/content/browser/android/in_process/synchronous_compositor_impl.cc
@@ -15,6 +15,7 @@
#include "content/browser/android/in_process/synchronous_input_event_filter.h"
#include "content/browser/renderer_host/render_widget_host_view_android.h"
#include "content/common/input/did_overscroll_params.h"
+#include "content/common/input_messages.h"
#include "content/public/browser/android/synchronous_compositor_client.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
@@ -287,10 +288,11 @@ void SynchronousCompositorImpl::DidOverscroll(
}
void SynchronousCompositorImpl::DidStopFlinging() {
- RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>(
- contents_->GetRenderWidgetHostView());
- if (rwhv)
- rwhv->DidStopFlinging();
+ // It's important that the fling-end notification follow the same path as it
+ // takes on other platforms (using an IPC). This ensures consistent
+ // bookkeeping at all stages of the input pipeline.
+ contents_->GetRenderProcessHost()->OnMessageReceived(
+ InputHostMsg_DidStopFlinging(routing_id_));
}
InputEventAckState SynchronousCompositorImpl::HandleInputEvent(
diff --git a/content/browser/renderer_host/input/input_router_impl.cc b/content/browser/renderer_host/input/input_router_impl.cc
index df02bb4..ed0ebb0 100644
--- a/content/browser/renderer_host/input/input_router_impl.cc
+++ b/content/browser/renderer_host/input/input_router_impl.cc
@@ -76,6 +76,7 @@ InputRouterImpl::InputRouterImpl(IPC::Sender* sender,
current_view_flags_(0),
current_ack_source_(ACK_SOURCE_NONE),
flush_requested_(false),
+ active_renderer_fling_count_(0),
touch_event_queue_(this, config.touch_config),
gesture_event_queue_(this, this, config.gesture_config) {
DCHECK(sender);
@@ -251,7 +252,8 @@ bool InputRouterImpl::HasPendingEvents() const {
mouse_move_pending_ ||
mouse_wheel_pending_ ||
select_message_pending_ ||
- move_caret_pending_;
+ move_caret_pending_ ||
+ active_renderer_fling_count_ > 0;
}
bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) {
@@ -497,8 +499,13 @@ void InputRouterImpl::OnSetTouchAction(TouchAction touch_action) {
}
void InputRouterImpl::OnDidStopFlinging() {
- // TODO(jdduke): Track fling status to allow flush notifications after a fling
- // has terminated, crbug.com/483037.
+ DCHECK_GT(active_renderer_fling_count_, 0);
+ // Note that we're only guaranteed to get a fling end notification from the
+ // renderer, not from any other consumers. Consequently, the GestureEventQueue
+ // cannot use this bookkeeping for logic like tap suppression.
+ --active_renderer_fling_count_;
+ SignalFlushedIfNecessary();
+
client_->DidStopFlinging();
}
@@ -603,6 +610,12 @@ void InputRouterImpl::ProcessWheelAck(InputEventAckState ack_result,
void InputRouterImpl::ProcessGestureAck(WebInputEvent::Type type,
InputEventAckState ack_result,
const ui::LatencyInfo& latency) {
+ if (type == blink::WebInputEvent::GestureFlingStart &&
+ ack_result == INPUT_EVENT_ACK_STATE_CONSUMED &&
+ current_ack_source_ == RENDERER) {
+ ++active_renderer_fling_count_;
+ }
+
// |gesture_event_queue_| will forward to OnGestureEventAck when appropriate.
gesture_event_queue_.ProcessGestureAck(ack_result, type, latency);
}
diff --git a/content/browser/renderer_host/input/input_router_impl.h b/content/browser/renderer_host/input/input_router_impl.h
index 1abe33b..73f9579 100644
--- a/content/browser/renderer_host/input/input_router_impl.h
+++ b/content/browser/renderer_host/input/input_router_impl.h
@@ -247,6 +247,11 @@ private:
// to the client_ after all events have been dispatched/acked.
bool flush_requested_;
+ // Whether there are any active flings in the renderer. As the fling
+ // end notification is asynchronous, we use a count rather than a boolean
+ // to avoid races in bookkeeping when starting a new fling.
+ int active_renderer_fling_count_;
+
TouchEventQueue touch_event_queue_;
GestureEventQueue gesture_event_queue_;
TouchActionFilter touch_action_filter_;
diff --git a/content/browser/renderer_host/input/input_router_impl_unittest.cc b/content/browser/renderer_host/input/input_router_impl_unittest.cc
index 83aab38..90ece24 100644
--- a/content/browser/renderer_host/input/input_router_impl_unittest.cc
+++ b/content/browser/renderer_host/input/input_router_impl_unittest.cc
@@ -1601,6 +1601,47 @@ TEST_F(InputRouterImplTest, InputFlush) {
EXPECT_FALSE(HasPendingEvents());
}
+// Test that the router will call the client's |DidFlush| after all fling
+// animations have completed.
+TEST_F(InputRouterImplTest, InputFlushAfterFling) {
+ EXPECT_FALSE(HasPendingEvents());
+
+ // Simulate a fling.
+ SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
+ blink::WebGestureDeviceTouchscreen);
+ SimulateGestureEvent(WebInputEvent::GestureFlingStart,
+ blink::WebGestureDeviceTouchscreen);
+ EXPECT_TRUE(HasPendingEvents());
+
+ // If the fling is unconsumed, the flush is complete.
+ RequestNotificationWhenFlushed();
+ EXPECT_EQ(0U, GetAndResetDidFlushCount());
+ SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
+ blink::WebGestureDeviceTouchscreen);
+ SendInputEventACK(WebInputEvent::GestureFlingStart,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_FALSE(HasPendingEvents());
+ EXPECT_EQ(1U, GetAndResetDidFlushCount());
+
+ // Simulate a second fling.
+ SimulateGestureEvent(WebInputEvent::GestureFlingStart,
+ blink::WebGestureDeviceTouchscreen);
+ EXPECT_TRUE(HasPendingEvents());
+
+ // If the fling is consumed, the flush is complete only when the renderer
+ // reports that is has ended.
+ RequestNotificationWhenFlushed();
+ EXPECT_EQ(0U, GetAndResetDidFlushCount());
+ SendInputEventACK(WebInputEvent::GestureFlingStart,
+ INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_TRUE(HasPendingEvents());
+ EXPECT_EQ(0U, GetAndResetDidFlushCount());
+
+ // The fling end notification should signal that the router is flushed.
+ input_router()->OnMessageReceived(InputHostMsg_DidStopFlinging(0));
+ EXPECT_EQ(1U, GetAndResetDidFlushCount());
+}
+
// Test that GesturePinchUpdate is handled specially for trackpad
TEST_F(InputRouterImplTest, TouchpadPinchUpdate) {
// GesturePinchUpdate for trackpad sends synthetic wheel events.
diff --git a/tools/perf/benchmarks/smoothness.py b/tools/perf/benchmarks/smoothness.py
index 4b20d94..8d3df64 100644
--- a/tools/perf/benchmarks/smoothness.py
+++ b/tools/perf/benchmarks/smoothness.py
@@ -247,7 +247,7 @@ class SmoothnessSimpleMobilePages(benchmark.Benchmark):
return 'smoothness.simple_mobile_sites'
-@benchmark.Disabled # crbug.com/483037
+@benchmark.Enabled('android')
class SmoothnessFlingSimpleMobilePages(benchmark.Benchmark):
"""Measures rendering statistics for flinging a simple mobile sites page set.
"""