Commit a0de839e authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

[Debugging] Add instrumentation in TouchActionFilter

From the stack trace of the current crash report, we are not able to
tell the gesture sequence, which makes it hard to debug.

This CL adds a CrashKeyString in TouchActionFilter, and push necessary
events into that string. When it crashes, we should be able to retrieve
the gesture sequence from that crash key.

Bug: 869375
Change-Id: Ieb7cf0839e4a062c23ec48cbaca72bd641f28a30
Reviewed-on: https://chromium-review.googlesource.com/1165586Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581676}
parent 31bb3259
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <math.h> #include <math.h>
#include "base/debug/crash_logging.h"
#include "base/debug/dump_without_crashing.h" #include "base/debug/dump_without_crashing.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
...@@ -42,7 +43,7 @@ TouchActionFilter::TouchActionFilter() ...@@ -42,7 +43,7 @@ TouchActionFilter::TouchActionFilter()
force_enable_zoom_(false) {} force_enable_zoom_(false) {}
TouchActionFilter::~TouchActionFilter() { TouchActionFilter::~TouchActionFilter() {
function_call_sequence_.clear(); gesture_sequence_.clear();
} }
FilterGestureEventResult TouchActionFilter::FilterGestureEvent( FilterGestureEventResult TouchActionFilter::FilterGestureEvent(
...@@ -56,6 +57,7 @@ FilterGestureEventResult TouchActionFilter::FilterGestureEvent( ...@@ -56,6 +57,7 @@ FilterGestureEventResult TouchActionFilter::FilterGestureEvent(
case WebInputEvent::kGestureScrollBegin: { case WebInputEvent::kGestureScrollBegin: {
DCHECK(!suppress_manipulation_events_); DCHECK(!suppress_manipulation_events_);
DCHECK(!touchscreen_scroll_in_progress_); DCHECK(!touchscreen_scroll_in_progress_);
gesture_sequence_.append("GSB ");
touchscreen_scroll_in_progress_ = true; touchscreen_scroll_in_progress_ = true;
// TODO(https://crbug.com/851644): Make sure the value is properly set. // TODO(https://crbug.com/851644): Make sure the value is properly set.
if (!scrolling_touch_action_.has_value()) if (!scrolling_touch_action_.has_value())
...@@ -101,7 +103,7 @@ FilterGestureEventResult TouchActionFilter::FilterGestureEvent( ...@@ -101,7 +103,7 @@ FilterGestureEventResult TouchActionFilter::FilterGestureEvent(
break; break;
case WebInputEvent::kGestureScrollEnd: case WebInputEvent::kGestureScrollEnd:
function_call_sequence_.clear(); gesture_sequence_.clear();
DCHECK(touchscreen_scroll_in_progress_); DCHECK(touchscreen_scroll_in_progress_);
touchscreen_scroll_in_progress_ = false; touchscreen_scroll_in_progress_ = false;
ReportGestureEventFiltered(suppress_manipulation_events_); ReportGestureEventFiltered(suppress_manipulation_events_);
...@@ -154,17 +156,10 @@ FilterGestureEventResult TouchActionFilter::FilterGestureEvent( ...@@ -154,17 +156,10 @@ FilterGestureEventResult TouchActionFilter::FilterGestureEvent(
scrolling_touch_action_ = allowed_touch_action_; scrolling_touch_action_ = allowed_touch_action_;
// TODO(https://crbug.com/851644): Make sure the value is properly set. // TODO(https://crbug.com/851644): Make sure the value is properly set.
if (!scrolling_touch_action_.has_value()) { if (!scrolling_touch_action_.has_value()) {
auto index_of_set = static auto* crash_key = base::debug::AllocateCrashKeyString(
std::find(std::begin(function_call_sequence_), "touchaction-gestures", base::debug::CrashKeySize::Size256);
std::end(function_call_sequence_), kOnSetTouchActionCall); base::debug::SetCrashKeyString(crash_key, gesture_sequence_);
auto index_of_reset = base::debug::DumpWithoutCrashing();
std::find(std::begin(function_call_sequence_),
std::end(function_call_sequence_), kResetTouchActionCall);
if (index_of_set != std::end(function_call_sequence_) &&
index_of_reset != std::end(function_call_sequence_) &&
index_of_reset > index_of_set) {
base::debug::DumpWithoutCrashing();
}
SetTouchAction(cc::kTouchActionAuto); SetTouchAction(cc::kTouchActionAuto);
} }
DCHECK(!drop_current_tap_ending_event_); DCHECK(!drop_current_tap_ending_event_);
...@@ -194,7 +189,7 @@ bool TouchActionFilter::FilterManipulationEventAndResetState() { ...@@ -194,7 +189,7 @@ bool TouchActionFilter::FilterManipulationEventAndResetState() {
void TouchActionFilter::OnSetTouchAction(cc::TouchAction touch_action) { void TouchActionFilter::OnSetTouchAction(cc::TouchAction touch_action) {
if (touch_action != cc::kTouchActionAuto) if (touch_action != cc::kTouchActionAuto)
function_call_sequence_.push_back(kOnSetTouchActionCall); gesture_sequence_.append("Set ");
// TODO(https://crbug.com/849819): add a DCHECK for // TODO(https://crbug.com/849819): add a DCHECK for
// |has_touch_event_handler_|. // |has_touch_event_handler_|.
// For multiple fingers, we take the intersection of the touch actions for // For multiple fingers, we take the intersection of the touch actions for
...@@ -253,7 +248,7 @@ void TouchActionFilter::ResetTouchAction() { ...@@ -253,7 +248,7 @@ void TouchActionFilter::ResetTouchAction() {
// their begin event(s) suppressed will be suppressed until the next // their begin event(s) suppressed will be suppressed until the next
// sequenceo. // sequenceo.
if (has_touch_event_handler_) { if (has_touch_event_handler_) {
function_call_sequence_.push_back(kResetTouchActionCall); gesture_sequence_.append("Reset ");
allowed_touch_action_.reset(); allowed_touch_action_.reset();
white_listed_touch_action_.reset(); white_listed_touch_action_.reset();
} else { } else {
......
...@@ -113,14 +113,7 @@ class CONTENT_EXPORT TouchActionFilter { ...@@ -113,14 +113,7 @@ class CONTENT_EXPORT TouchActionFilter {
// Whitelisted touch action received from the compositor. // Whitelisted touch action received from the compositor.
base::Optional<cc::TouchAction> white_listed_touch_action_; base::Optional<cc::TouchAction> white_listed_touch_action_;
// DEBUG ONLY! Record the sequence of function calls, cleared at GSE. When it std::string gesture_sequence_;
// is GSB and |scrolling_touch_action_| has no value, check this sequence.
enum FunctionCalls {
kOnSetTouchActionCall,
kResetTouchActionCall,
};
std::vector<FunctionCalls> function_call_sequence_;
DISALLOW_COPY_AND_ASSIGN(TouchActionFilter); DISALLOW_COPY_AND_ASSIGN(TouchActionFilter);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment