Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: ui/events/blink/input_handler_proxy.cc

Issue 2636583002: UMA metrics for fractions of wheel and touch scrolls blocked on the main thread. (Closed)
Patch Set: RecordScrollingThreadStatus called in FlingScrollByMouseWheel. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/blink/input_handler_proxy.h ('k') | ui/events/blink/input_handler_proxy_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/events/blink/input_handler_proxy.h" 5 #include "ui/events/blink/input_handler_proxy.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 225 }
226 } 226 }
227 227
228 cc::InputHandler::ScrollInputType GestureScrollInputType( 228 cc::InputHandler::ScrollInputType GestureScrollInputType(
229 blink::WebGestureDevice device) { 229 blink::WebGestureDevice device) {
230 return device == blink::WebGestureDeviceTouchpad 230 return device == blink::WebGestureDeviceTouchpad
231 ? cc::InputHandler::WHEEL 231 ? cc::InputHandler::WHEEL
232 : cc::InputHandler::TOUCHSCREEN; 232 : cc::InputHandler::TOUCHSCREEN;
233 } 233 }
234 234
235 enum ScrollingThreadStatus {
236 SCROLLING_ON_COMPOSITOR,
237 SCROLLING_ON_COMPOSITOR_BLOCKED_ON_MAIN,
238 SCROLLING_ON_MAIN,
239 LAST_SCROLLING_THREAD_STATUS_VALUE = SCROLLING_ON_MAIN,
240 };
241
235 } // namespace 242 } // namespace
236 243
237 namespace ui { 244 namespace ui {
238 245
239 InputHandlerProxy::InputHandlerProxy(cc::InputHandler* input_handler, 246 InputHandlerProxy::InputHandlerProxy(cc::InputHandler* input_handler,
240 InputHandlerProxyClient* client) 247 InputHandlerProxyClient* client)
241 : client_(client), 248 : client_(client),
242 input_handler_(input_handler), 249 input_handler_(input_handler),
243 deferred_fling_cancel_time_seconds_(0), 250 deferred_fling_cancel_time_seconds_(0),
244 synchronous_input_handler_(nullptr), 251 synchronous_input_handler_(nullptr),
245 allow_root_animate_(true), 252 allow_root_animate_(true),
246 #ifndef NDEBUG 253 #ifndef NDEBUG
247 expect_scroll_update_end_(false), 254 expect_scroll_update_end_(false),
248 #endif 255 #endif
249 gesture_scroll_on_impl_thread_(false), 256 gesture_scroll_on_impl_thread_(false),
250 gesture_pinch_on_impl_thread_(false), 257 gesture_pinch_on_impl_thread_(false),
251 fling_may_be_active_on_main_thread_(false), 258 fling_may_be_active_on_main_thread_(false),
252 disallow_horizontal_fling_scroll_(false), 259 disallow_horizontal_fling_scroll_(false),
253 disallow_vertical_fling_scroll_(false), 260 disallow_vertical_fling_scroll_(false),
254 has_fling_animation_started_(false), 261 has_fling_animation_started_(false),
255 smooth_scroll_enabled_(false), 262 smooth_scroll_enabled_(false),
256 uma_latency_reporting_enabled_(base::TimeTicks::IsHighResolution()), 263 uma_latency_reporting_enabled_(base::TimeTicks::IsHighResolution()),
257 touchpad_and_wheel_scroll_latching_enabled_(false), 264 touchpad_and_wheel_scroll_latching_enabled_(false),
258 touch_start_result_(kEventDispositionUndefined), 265 touch_start_result_(kEventDispositionUndefined),
266 mouse_wheel_result_(kEventDispositionUndefined),
259 current_overscroll_params_(nullptr), 267 current_overscroll_params_(nullptr),
260 has_ongoing_compositor_scroll_pinch_(false), 268 has_ongoing_compositor_scroll_pinch_(false),
261 tick_clock_(base::MakeUnique<base::DefaultTickClock>()) { 269 tick_clock_(base::MakeUnique<base::DefaultTickClock>()) {
262 DCHECK(client); 270 DCHECK(client);
263 input_handler_->BindToClient(this); 271 input_handler_->BindToClient(this);
264 cc::ScrollElasticityHelper* scroll_elasticity_helper = 272 cc::ScrollElasticityHelper* scroll_elasticity_helper =
265 input_handler_->CreateScrollElasticityHelper(); 273 input_handler_->CreateScrollElasticityHelper();
266 if (scroll_elasticity_helper) { 274 if (scroll_elasticity_helper) {
267 scroll_elasticity_controller_.reset( 275 scroll_elasticity_controller_.reset(
268 new InputScrollElasticityController(scroll_elasticity_helper)); 276 new InputScrollElasticityController(scroll_elasticity_helper));
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 UMA_HISTOGRAM_ENUMERATION(kGestureHistogramName, i + 1, 586 UMA_HISTOGRAM_ENUMERATION(kGestureHistogramName, i + 1,
579 mainThreadScrollingReasonEnumMax); 587 mainThreadScrollingReasonEnumMax);
580 } else { 588 } else {
581 UMA_HISTOGRAM_ENUMERATION(kWheelHistogramName, i + 1, 589 UMA_HISTOGRAM_ENUMERATION(kWheelHistogramName, i + 1,
582 mainThreadScrollingReasonEnumMax); 590 mainThreadScrollingReasonEnumMax);
583 } 591 }
584 } 592 }
585 } 593 }
586 } 594 }
587 595
596 void InputHandlerProxy::RecordScrollingThreadStatus(
597 blink::WebGestureDevice device,
598 uint32_t reasons) {
599 static const char* kGestureHistogramName =
600 "Renderer4.GestureScrollingThreadStatus";
601 static const char* kWheelHistogramName =
602 "Renderer4.WheelScrollingThreadStatus";
603
604 DCHECK(device == blink::WebGestureDeviceTouchpad ||
605 device == blink::WebGestureDeviceTouchscreen);
606
607 if (device != blink::WebGestureDeviceTouchpad &&
608 device != blink::WebGestureDeviceTouchscreen) {
609 return;
610 }
611
612 ScrollingThreadStatus scrolling_thread_status = SCROLLING_ON_MAIN;
613 if (reasons == cc::MainThreadScrollingReason::kNotScrollingOnMain) {
614 int32_t event_disposition_result =
615 (device == blink::WebGestureDeviceTouchpad ? mouse_wheel_result_
616 : touch_start_result_);
617 switch (event_disposition_result) {
618 case kEventDispositionUndefined:
619 case DID_NOT_HANDLE_NON_BLOCKING_DUE_TO_FLING:
620 case DID_HANDLE_NON_BLOCKING:
621 case DROP_EVENT:
622 scrolling_thread_status = SCROLLING_ON_COMPOSITOR;
623 break;
624 case DID_NOT_HANDLE:
625 scrolling_thread_status = SCROLLING_ON_COMPOSITOR_BLOCKED_ON_MAIN;
626 break;
627 default:
628 NOTREACHED();
629 scrolling_thread_status = SCROLLING_ON_COMPOSITOR;
630 }
631 }
632
633 // UMA_HISTOGRAM_ENUMERATION requires that the enum_max must be strictly
634 // greater than the sample value.
635 const uint32_t kScrolingThreadStatusEnumMax =
636 ScrollingThreadStatus::LAST_SCROLLING_THREAD_STATUS_VALUE + 1;
637
638 if (device == blink::WebGestureDeviceTouchscreen) {
639 UMA_HISTOGRAM_ENUMERATION(kGestureHistogramName, scrolling_thread_status,
tdresser 2017/01/17 20:27:43 I'd probably just put the literal string in here,
sahel 2017/01/19 15:26:32 Done.
640 kScrolingThreadStatusEnumMax);
641 } else {
642 UMA_HISTOGRAM_ENUMERATION(kWheelHistogramName, scrolling_thread_status,
643 kScrolingThreadStatusEnumMax);
644 }
645 }
646
588 bool InputHandlerProxy::ShouldAnimate(bool has_precise_scroll_deltas) const { 647 bool InputHandlerProxy::ShouldAnimate(bool has_precise_scroll_deltas) const {
589 #if defined(OS_MACOSX) 648 #if defined(OS_MACOSX)
590 // Mac does not smooth scroll wheel events (crbug.com/574283). 649 // Mac does not smooth scroll wheel events (crbug.com/574283).
591 return false; 650 return false;
592 #else 651 #else
593 return smooth_scroll_enabled_ && !has_precise_scroll_deltas; 652 return smooth_scroll_enabled_ && !has_precise_scroll_deltas;
594 #endif 653 #endif
595 } 654 }
596 655
597 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel( 656 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel(
598 const WebMouseWheelEvent& wheel_event) { 657 const WebMouseWheelEvent& wheel_event) {
599 // Only call |CancelCurrentFling()| if a fling was active, as it will 658 // Only call |CancelCurrentFling()| if a fling was active, as it will
600 // otherwise disrupt an in-progress touch scroll. 659 // otherwise disrupt an in-progress touch scroll.
601 if (!wheel_event.hasPreciseScrollingDeltas && fling_curve_) 660 if (!wheel_event.hasPreciseScrollingDeltas && fling_curve_)
602 CancelCurrentFling(); 661 CancelCurrentFling();
603 662
663 InputHandlerProxy::EventDisposition result = DROP_EVENT;
604 cc::EventListenerProperties properties = 664 cc::EventListenerProperties properties =
605 input_handler_->GetEventListenerProperties( 665 input_handler_->GetEventListenerProperties(
606 cc::EventListenerClass::kMouseWheel); 666 cc::EventListenerClass::kMouseWheel);
607 switch (properties) { 667 switch (properties) {
608 case cc::EventListenerProperties::kPassive: 668 case cc::EventListenerProperties::kPassive:
609 return DID_HANDLE_NON_BLOCKING; 669 result = DID_HANDLE_NON_BLOCKING;
670 break;
610 case cc::EventListenerProperties::kBlockingAndPassive: 671 case cc::EventListenerProperties::kBlockingAndPassive:
611 case cc::EventListenerProperties::kBlocking: 672 case cc::EventListenerProperties::kBlocking:
612 return DID_NOT_HANDLE; 673 result = DID_NOT_HANDLE;
674 break;
613 case cc::EventListenerProperties::kNone: 675 case cc::EventListenerProperties::kNone:
614 return DROP_EVENT; 676 result = DROP_EVENT;
677 break;
615 default: 678 default:
616 NOTREACHED(); 679 NOTREACHED();
617 return DROP_EVENT; 680 result = DROP_EVENT;
618 } 681 }
682
683 mouse_wheel_result_ = result;
684 return result;
619 } 685 }
620 686
621 InputHandlerProxy::EventDisposition InputHandlerProxy::FlingScrollByMouseWheel( 687 InputHandlerProxy::EventDisposition InputHandlerProxy::FlingScrollByMouseWheel(
622 const WebMouseWheelEvent& wheel_event, 688 const WebMouseWheelEvent& wheel_event,
623 cc::EventListenerProperties listener_properties) { 689 cc::EventListenerProperties listener_properties) {
624 DCHECK(listener_properties == cc::EventListenerProperties::kPassive || 690 DCHECK(listener_properties == cc::EventListenerProperties::kPassive ||
625 listener_properties == cc::EventListenerProperties::kNone); 691 listener_properties == cc::EventListenerProperties::kNone);
626 692
627 DCHECK(!wheel_event.railsMode); 693 DCHECK(!wheel_event.railsMode);
628 gfx::Vector2dF scroll_delta(-wheel_event.deltaX, -wheel_event.deltaY); 694 gfx::Vector2dF scroll_delta(-wheel_event.deltaX, -wheel_event.deltaY);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 scroll_state_begin_data.position_y = wheel_event.y; 729 scroll_state_begin_data.position_y = wheel_event.y;
664 scroll_state_begin_data.is_beginning = true; 730 scroll_state_begin_data.is_beginning = true;
665 cc::ScrollState scroll_state_begin(scroll_state_begin_data); 731 cc::ScrollState scroll_state_begin(scroll_state_begin_data);
666 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( 732 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin(
667 &scroll_state_begin, cc::InputHandler::WHEEL); 733 &scroll_state_begin, cc::InputHandler::WHEEL);
668 734
669 RecordMainThreadScrollingReasons( 735 RecordMainThreadScrollingReasons(
670 blink::WebGestureDeviceTouchpad, 736 blink::WebGestureDeviceTouchpad,
671 scroll_status.main_thread_scrolling_reasons); 737 scroll_status.main_thread_scrolling_reasons);
672 738
739 mouse_wheel_result_ =
740 (listener_properties == cc::EventListenerProperties::kPassive)
741 ? DID_HANDLE_NON_BLOCKING
742 : DROP_EVENT;
743 RecordScrollingThreadStatus(blink::WebGestureDeviceTouchpad,
744 scroll_status.main_thread_scrolling_reasons);
745
673 switch (scroll_status.thread) { 746 switch (scroll_status.thread) {
674 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: { 747 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: {
675 TRACE_EVENT_INSTANT2("input", 748 TRACE_EVENT_INSTANT2("input",
676 "InputHandlerProxy::handle_input wheel scroll", 749 "InputHandlerProxy::handle_input wheel scroll",
677 TRACE_EVENT_SCOPE_THREAD, "deltaX", 750 TRACE_EVENT_SCOPE_THREAD, "deltaX",
678 scroll_delta.x(), "deltaY", scroll_delta.y()); 751 scroll_delta.x(), "deltaY", scroll_delta.y());
679 752
680 cc::ScrollStateData scroll_state_update_data; 753 cc::ScrollStateData scroll_state_update_data;
681 scroll_state_update_data.delta_x = scroll_delta.x(); 754 scroll_state_update_data.delta_x = scroll_delta.x();
682 scroll_state_update_data.delta_y = scroll_delta.y(); 755 scroll_state_update_data.delta_y = scroll_delta.y();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 } else { 817 } else {
745 scroll_status = input_handler_->ScrollBegin( 818 scroll_status = input_handler_->ScrollBegin(
746 &scroll_state, GestureScrollInputType(gesture_event.sourceDevice)); 819 &scroll_state, GestureScrollInputType(gesture_event.sourceDevice));
747 } 820 }
748 UMA_HISTOGRAM_ENUMERATION("Renderer4.CompositorScrollHitTestResult", 821 UMA_HISTOGRAM_ENUMERATION("Renderer4.CompositorScrollHitTestResult",
749 scroll_status.thread, 822 scroll_status.thread,
750 cc::InputHandler::LAST_SCROLL_STATUS + 1); 823 cc::InputHandler::LAST_SCROLL_STATUS + 1);
751 824
752 RecordMainThreadScrollingReasons(gesture_event.sourceDevice, 825 RecordMainThreadScrollingReasons(gesture_event.sourceDevice,
753 scroll_status.main_thread_scrolling_reasons); 826 scroll_status.main_thread_scrolling_reasons);
827 RecordScrollingThreadStatus(gesture_event.sourceDevice,
828 scroll_status.main_thread_scrolling_reasons);
754 829
755 InputHandlerProxy::EventDisposition result = DID_NOT_HANDLE; 830 InputHandlerProxy::EventDisposition result = DID_NOT_HANDLE;
756 switch (scroll_status.thread) { 831 switch (scroll_status.thread) {
757 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: 832 case cc::InputHandler::SCROLL_ON_IMPL_THREAD:
758 TRACE_EVENT_INSTANT0("input", 833 TRACE_EVENT_INSTANT0("input",
759 "InputHandlerProxy::handle_input gesture scroll", 834 "InputHandlerProxy::handle_input gesture scroll",
760 TRACE_EVENT_SCOPE_THREAD); 835 TRACE_EVENT_SCOPE_THREAD);
761 gesture_scroll_on_impl_thread_ = true; 836 gesture_scroll_on_impl_thread_ = true;
762 result = DID_HANDLE; 837 result = DID_HANDLE;
763 break; 838 break;
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, 1615 scroll_elasticity_controller_->GetWeakPtr(), gesture_event,
1541 scroll_result)); 1616 scroll_result));
1542 } 1617 }
1543 1618
1544 void InputHandlerProxy::SetTickClockForTesting( 1619 void InputHandlerProxy::SetTickClockForTesting(
1545 std::unique_ptr<base::TickClock> tick_clock) { 1620 std::unique_ptr<base::TickClock> tick_clock) {
1546 tick_clock_ = std::move(tick_clock); 1621 tick_clock_ = std::move(tick_clock);
1547 } 1622 }
1548 1623
1549 } // namespace ui 1624 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/blink/input_handler_proxy.h ('k') | ui/events/blink/input_handler_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698