Commit 235ea825 authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

[Debugging] Do DumpWithoutCrashing once every 100 times in TouchActionFilter

Right now in TouchActionFilters we have DumpWithoutCrashing for debugging
purpose. Since there are too many reports, it could impact the decision
of which crash is more important.

This CL makes the report to be generated once every 100 times.

Bug: None
Change-Id: Ie370f0bdbf5d84e2bcf410fbf06a183f9b20aa6f
Reviewed-on: https://chromium-review.googlesource.com/1179609
Commit-Queue: Xida Chen <xidachen@chromium.org>
Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584166}
parent 67e36d28
......@@ -44,6 +44,15 @@ TouchActionFilter::TouchActionFilter()
TouchActionFilter::~TouchActionFilter() {}
// In all the places that has DumpWithCrashing(), generate a report once every
// 100 times.
bool TouchActionFilter::ShouldDump() {
std::uniform_int_distribution<int> uniform_dist(0, 99);
if (uniform_dist(gen_) == 0)
return true;
return false;
}
FilterGestureEventResult TouchActionFilter::FilterGestureEvent(
WebGestureEvent* gesture_event) {
if (gesture_event->SourceDevice() != blink::kWebGestureDeviceTouchscreen)
......@@ -59,10 +68,13 @@ FilterGestureEventResult TouchActionFilter::FilterGestureEvent(
gesture_sequence_.append("B");
// TODO(https://crbug.com/851644): Make sure the value is properly set.
if (!scrolling_touch_action_.has_value()) {
static auto* crash_key = base::debug::AllocateCrashKeyString(
"scrollbegin-gestures", base::debug::CrashKeySize::Size256);
base::debug::SetCrashKeyString(crash_key, gesture_sequence_);
base::debug::DumpWithoutCrashing();
if (ShouldDump()) {
static auto* crash_key = base::debug::AllocateCrashKeyString(
"scrollbegin-gestures", base::debug::CrashKeySize::Size256);
base::debug::SetCrashKeyString(crash_key, gesture_sequence_);
base::debug::DumpWithoutCrashing();
}
gesture_sequence_.clear();
SetTouchAction(cc::kTouchActionAuto);
}
suppress_manipulation_events_ =
......@@ -135,10 +147,13 @@ FilterGestureEventResult TouchActionFilter::FilterGestureEvent(
DCHECK_EQ(1, gesture_event->data.tap.tap_count);
// TODO(https://crbug.com/851644): Make sure the value is properly set.
if (!scrolling_touch_action_.has_value()) {
static auto* crash_key = base::debug::AllocateCrashKeyString(
"tapunconfirmed-gestures", base::debug::CrashKeySize::Size256);
base::debug::SetCrashKeyString(crash_key, gesture_sequence_);
base::debug::DumpWithoutCrashing();
if (ShouldDump()) {
static auto* crash_key = base::debug::AllocateCrashKeyString(
"tapunconfirmed-gestures", base::debug::CrashKeySize::Size256);
base::debug::SetCrashKeyString(crash_key, gesture_sequence_);
base::debug::DumpWithoutCrashing();
}
gesture_sequence_.clear();
SetTouchAction(cc::kTouchActionAuto);
}
allow_current_double_tap_event_ = (scrolling_touch_action_.value() &
......@@ -168,10 +183,13 @@ FilterGestureEventResult TouchActionFilter::FilterGestureEvent(
scrolling_touch_action_ = allowed_touch_action_;
// TODO(https://crbug.com/851644): Make sure the value is properly set.
if (!scrolling_touch_action_.has_value()) {
static auto* crash_key = base::debug::AllocateCrashKeyString(
"tapdown-gestures", base::debug::CrashKeySize::Size256);
base::debug::SetCrashKeyString(crash_key, gesture_sequence_);
base::debug::DumpWithoutCrashing();
if (ShouldDump()) {
static auto* crash_key = base::debug::AllocateCrashKeyString(
"tapdown-gestures", base::debug::CrashKeySize::Size256);
base::debug::SetCrashKeyString(crash_key, gesture_sequence_);
base::debug::DumpWithoutCrashing();
}
gesture_sequence_.clear();
SetTouchAction(cc::kTouchActionAuto);
}
DCHECK(!drop_current_tap_ending_event_);
......
......@@ -5,6 +5,8 @@
#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_ACTION_FILTER_H_
#define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_ACTION_FILTER_H_
#include <random>
#include "base/macros.h"
#include "base/optional.h"
#include "cc/input/touch_action.h"
......@@ -79,6 +81,9 @@ class CONTENT_EXPORT TouchActionFilter {
void ReportTouchAction();
void SetTouchAction(cc::TouchAction touch_action);
// Debugging only.
bool ShouldDump();
// Whether scroll and pinch gestures should be discarded due to touch-action.
bool suppress_manipulation_events_;
......@@ -118,6 +123,7 @@ class CONTENT_EXPORT TouchActionFilter {
// Debugging only.
std::string gesture_sequence_;
std::default_random_engine gen_;
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