Bug 1670003 - Add back the scroll input methods telemetry. r=botond

This is mostly a revert of the patch in bug 1425686 that removed the old
probe, but rebased to new code locations and clang-formatted. The histogram
entry is also updated with new bug numbers and fields.

The next patch will refine some of these telemetry recording points; the patch
is split into two for easier reviewing as this part is basically what landed
originally.

Differential Revision: https://phabricator.services.mozilla.com/D92995
This commit is contained in:
Kartikaya Gupta 2020-10-10 17:41:47 +00:00
Родитель 935ea057dd
Коммит 264e82488a
13 изменённых файлов: 230 добавлений и 0 удалений

Просмотреть файл

@ -23,6 +23,7 @@
#include "mozilla/ErrorResult.h"
#include "mozilla/EventStates.h"
#include "mozilla/HTMLEditor.h"
#include "mozilla/layers/ScrollInputMethods.h"
#include "mozilla/PresShell.h"
#include "mozilla/RangeBoundary.h"
#include "mozilla/RangeUtils.h"
@ -77,6 +78,7 @@
using namespace mozilla;
using namespace mozilla::dom;
using mozilla::layers::ScrollInputMethod;
//#define DEBUG_TABLE 1
@ -2981,6 +2983,12 @@ nsresult Selection::ScrollIntoView(SelectionRegion aRegion,
scrollFlags |= ScrollFlags::ScrollOverflowHidden;
}
if (aFlags & Selection::SCROLL_FOR_CARET_MOVE) {
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::MainThreadScrollCaretIntoView);
}
presShell->ScrollFrameRectIntoView(frame, rect, aVertical, aHorizontal,
scrollFlags);
return NS_OK;

Просмотреть файл

@ -39,6 +39,7 @@
#include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/dom/HTMLTextAreaElement.h"
#include "mozilla/dom/Text.h"
#include "mozilla/layers/ScrollInputMethods.h"
#include "mozilla/StaticPrefs_dom.h"
#include "nsFrameSelection.h"
#include "mozilla/ErrorResult.h"
@ -51,6 +52,7 @@
namespace mozilla {
using namespace dom;
using layers::ScrollInputMethod;
/*****************************************************************************
* TextControlElement
@ -653,6 +655,11 @@ TextInputSelectionController::CompleteScroll(bool aForward) {
if (!mScrollFrame) {
return NS_ERROR_NOT_INITIALIZED;
}
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::MainThreadCompleteScroll);
mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::WHOLE,
ScrollMode::Instant);
return NS_OK;
@ -704,6 +711,11 @@ TextInputSelectionController::ScrollPage(bool aForward) {
if (!mScrollFrame) {
return NS_ERROR_NOT_INITIALIZED;
}
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::MainThreadScrollPage);
mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::PAGES,
ScrollMode::Smooth);
return NS_OK;
@ -714,6 +726,11 @@ TextInputSelectionController::ScrollLine(bool aForward) {
if (!mScrollFrame) {
return NS_ERROR_NOT_INITIALIZED;
}
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::MainThreadScrollLine);
mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::LINES,
ScrollMode::Smooth);
return NS_OK;
@ -724,6 +741,11 @@ TextInputSelectionController::ScrollCharacter(bool aRight) {
if (!mScrollFrame) {
return NS_ERROR_NOT_INITIALIZED;
}
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::MainThreadScrollCharacter);
mScrollFrame->ScrollBy(nsIntPoint(aRight ? 1 : -1, 0), ScrollUnit::LINES,
ScrollMode::Smooth);
return NS_OK;

Просмотреть файл

@ -72,6 +72,7 @@
#include "mozilla/layers/DirectionUtils.h" // for GetAxis{Start,End,Length,Scale}
#include "mozilla/layers/LayerTransactionParent.h" // for LayerTransactionParent
#include "mozilla/layers/MetricsSharingController.h" // for MetricsSharingController
#include "mozilla/layers/ScrollInputMethods.h" // for ScrollInputMethod
#include "mozilla/mozalloc.h" // for operator new, etc
#include "mozilla/Unused.h" // for unused
#include "mozilla/FloatingPoint.h" // for FuzzyEquals*
@ -943,6 +944,9 @@ nsEventStatus AsyncPanZoomController::HandleDragEvent(
MOZ_ASSERT(scrollbarData.mDirection.isSome());
ScrollDirection direction = *scrollbarData.mDirection;
mozilla::Telemetry::Accumulate(mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::ApzScrollbarDrag);
bool isMouseAwayFromThumb = false;
if (int snapMultiplier = StaticPrefs::slider_snapMultiplier_AtStartup()) {
// It's fine to ignore the async component of the thumb's transform,
@ -1892,7 +1896,36 @@ ParentLayerPoint AsyncPanZoomController::GetScrollWheelDelta(
return delta;
}
static void ReportKeyboardScrollAction(const KeyboardScrollAction& aAction) {
ScrollInputMethod scrollMethod;
switch (aAction.mType) {
case KeyboardScrollAction::eScrollLine: {
scrollMethod = ScrollInputMethod::ApzScrollLine;
break;
}
case KeyboardScrollAction::eScrollCharacter: {
scrollMethod = ScrollInputMethod::ApzScrollCharacter;
break;
}
case KeyboardScrollAction::eScrollPage: {
scrollMethod = ScrollInputMethod::ApzScrollPage;
break;
}
case KeyboardScrollAction::eScrollComplete: {
scrollMethod = ScrollInputMethod::ApzCompleteScroll;
break;
}
}
mozilla::Telemetry::Accumulate(mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)scrollMethod);
}
nsEventStatus AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent) {
// Report the type of scroll action to telemetry
ReportKeyboardScrollAction(aEvent.mAction);
// Mark that this APZC has async key scrolled
mTestHasAsyncKeyScrolled = true;
@ -2170,6 +2203,23 @@ void AsyncPanZoomController::DoDelayedRequestContentRepaint() {
mPinchPaintTimerSet = false;
}
static ScrollInputMethod ScrollInputMethodForWheelDeltaType(
ScrollWheelInput::ScrollDeltaType aDeltaType) {
switch (aDeltaType) {
case ScrollWheelInput::SCROLLDELTA_LINE: {
return ScrollInputMethod::ApzWheelLine;
}
case ScrollWheelInput::SCROLLDELTA_PAGE: {
return ScrollInputMethod::ApzWheelPage;
}
case ScrollWheelInput::SCROLLDELTA_PIXEL: {
return ScrollInputMethod::ApzWheelPixel;
}
}
MOZ_ASSERT_UNREACHABLE("Invalid value");
return ScrollInputMethod::ApzWheelLine;
}
static void AdjustDeltaForAllowedScrollDirections(
ParentLayerPoint& aDelta,
const ScrollDirections& aAllowedScrollDirections) {
@ -2254,6 +2304,10 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel(
return nsEventStatus_eIgnore;
}
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethodForWheelDeltaType(aEvent.mDeltaType));
switch (aEvent.mScrollMode) {
case ScrollWheelInput::SCROLLMODE_INSTANT: {
// Wheel events from "clicky" mouse wheels trigger scroll snapping to the
@ -2519,6 +2573,9 @@ nsEventStatus AsyncPanZoomController::OnPan(const PanGestureInput& aEvent,
HandlePanningUpdate(physicalPanDisplacement);
mozilla::Telemetry::Accumulate(mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::ApzPanGesture);
ScreenPoint panDistance(fabs(physicalPanDisplacement.x),
fabs(physicalPanDisplacement.y));
OverscrollHandoffState handoffState(
@ -3506,6 +3563,8 @@ void AsyncPanZoomController::TrackTouch(const MultiTouchInput& aEvent) {
UpdateWithTouchAtDevicePoint(aEvent);
if (prevTouchPoint != touchPoint) {
mozilla::Telemetry::Accumulate(mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::ApzTouch);
MOZ_ASSERT(GetCurrentTouchBlock());
OverscrollHandoffState handoffState(
*GetCurrentTouchBlock()->GetOverscrollHandoffChain(), panVector,

Просмотреть файл

@ -12,6 +12,7 @@
#include "APZCTreeManager.h"
#include "FrameMetrics.h"
#include "mozilla/Telemetry.h" // for Telemetry
#include "mozilla/layers/ScrollInputMethods.h" // for ScrollInputMethod
namespace mozilla {
namespace layers {
@ -41,6 +42,9 @@ bool AutoscrollAnimation::DoSample(FrameMetrics& aFrameMetrics,
return false;
}
Telemetry::Accumulate(Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::ApzAutoscrolling);
ScreenPoint mouseLocation = treeManager->GetCurrentMousePosition();
// The implementation of this function closely mirrors that of its main-

Просмотреть файл

@ -0,0 +1,78 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_layers_ScrollInputMethods_h
#define mozilla_layers_ScrollInputMethods_h
namespace mozilla {
namespace layers {
/**
* An enumeration that lists various input methods used to trigger scrolling.
* Used as the values for the SCROLL_INPUT_METHODS telemetry histogram.
*/
enum class ScrollInputMethod {
// === Driven by APZ ===
ApzTouch, // touch events
ApzWheelPixel, // wheel events, pixel scrolling mode
ApzWheelLine, // wheel events, line scrolling mode
ApzWheelPage, // wheel events, page scrolling mode
ApzPanGesture, // pan gesture events (generally triggered by trackpad)
ApzScrollbarDrag, // dragging the scrollbar
// === Driven by the main thread ===
// Keyboard
MainThreadScrollLine, // line scrolling
// (generally triggered by up/down arrow keys)
MainThreadScrollCharacter, // character scrolling
// (generally triggered by left/right arrow keys)
MainThreadScrollPage, // page scrolling
// (generally triggered by PageUp/PageDown keys)
MainThreadCompleteScroll, // scrolling to the end of the scroll range
// (generally triggered by Home/End keys)
MainThreadScrollCaretIntoView, // scrolling to bring the caret into view
// after moving the caret via the keyboard
// Touch
MainThreadTouch, // touch events
// Scrollbar
MainThreadScrollbarDrag, // dragging the scrollbar
MainThreadScrollbarButtonClick, // clicking the buttons at the ends of the
// scrollback track
MainThreadScrollbarTrackClick, // clicking the scrollbar track above or
// below the thumb
// Autoscrolling
MainThreadAutoscrolling, // autoscrolling
// === Additional input methods implemented in APZ ===
// Async Keyboard
ApzScrollLine, // line scrolling
// (generally triggered by up/down arrow keys)
ApzScrollCharacter, // character scrolling
// (generally triggered by left/right arrow keys)
ApzScrollPage, // page scrolling
// (generally triggered by PageUp/PageDown keys)
ApzCompleteScroll, // scrolling to the end of the scroll range
// (generally triggered by Home/End keys)
// Autoscrolling
ApzAutoscrolling,
// New input methods can be added at the end, up to a maximum of 64.
// They should only be added at the end, to preserve the numerical values
// of the existing enumerators.
};
} // namespace layers
} // namespace mozilla
#endif /* mozilla_layers_ScrollInputMethods_h */

Просмотреть файл

@ -124,6 +124,7 @@ EXPORTS.mozilla.layers += [
'apz/util/ContentProcessController.h',
'apz/util/DoubleTapToZoom.h',
'apz/util/InputAPZContext.h',
'apz/util/ScrollInputMethods.h',
'apz/util/ScrollLinkedEffectDetector.h',
'apz/util/TouchActionHelper.h',
'apz/util/TouchCounter.h',

Просмотреть файл

@ -188,6 +188,7 @@
#include "nsQueryObject.h"
#include "mozilla/GlobalStyleSheetCache.h"
#include "mozilla/layers/InputAPZContext.h"
#include "mozilla/layers/ScrollInputMethods.h"
#include "mozilla/layers/FocusTarget.h"
#include "mozilla/layers/WebRenderLayerManager.h"
#include "mozilla/layers/WebRenderUserData.h"
@ -2360,6 +2361,9 @@ PresShell::ScrollPage(bool aForward) {
nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(ScrollableDirection::Vertical);
if (scrollFrame) {
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::MainThreadScrollPage);
scrollFrame->ScrollBy(
nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::PAGES, ScrollMode::Smooth,
nullptr, mozilla::ScrollOrigin::NotSpecified,
@ -2373,6 +2377,9 @@ PresShell::ScrollLine(bool aForward) {
nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(ScrollableDirection::Vertical);
if (scrollFrame) {
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::MainThreadScrollLine);
int32_t lineCount =
Preferences::GetInt("toolkit.scrollbox.verticalScrollDistance",
NS_DEFAULT_VERTICAL_SCROLL_DISTANCE);
@ -2389,6 +2396,9 @@ PresShell::ScrollCharacter(bool aRight) {
nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(ScrollableDirection::Horizontal);
if (scrollFrame) {
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::MainThreadScrollCharacter);
int32_t h =
Preferences::GetInt("toolkit.scrollbox.horizontalScrollDistance",
NS_DEFAULT_HORIZONTAL_SCROLL_DISTANCE);
@ -2405,6 +2415,9 @@ PresShell::CompleteScroll(bool aForward) {
nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(ScrollableDirection::Vertical);
if (scrollFrame) {
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::MainThreadCompleteScroll);
scrollFrame->ScrollBy(
nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::WHOLE, ScrollMode::Smooth,
nullptr, mozilla::ScrollOrigin::NotSpecified,

Просмотреть файл

@ -77,12 +77,14 @@ static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID);
#include "mozilla/dom/SelectionBinding.h"
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/Telemetry.h"
#include "mozilla/layers/ScrollInputMethods.h"
#include "nsFocusManager.h"
#include "nsPIDOMWindow.h"
using namespace mozilla;
using namespace mozilla::dom;
using mozilla::layers::ScrollInputMethod;
//#define DEBUG_TABLE 1
@ -1921,6 +1923,10 @@ nsresult nsFrameSelection::PageMove(bool aForward, bool aExtend,
// Then, scroll the given frame one page.
if (scrollableFrame) {
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::MainThreadScrollPage);
// If we'll call ScrollSelectionIntoView later and selection wasn't
// changed and we scroll outside of selection limiter, we shouldn't use
// smooth scroll here because nsIScrollableFrame uses normal runnable,

Просмотреть файл

@ -26,8 +26,10 @@
#include "mozilla/MouseEvents.h"
#include "mozilla/PresShell.h"
#include "mozilla/Telemetry.h"
#include "mozilla/layers/ScrollInputMethods.h"
using namespace mozilla;
using mozilla::layers::ScrollInputMethod;
//
// NS_NewToolbarFrame
@ -166,6 +168,10 @@ bool nsScrollbarButtonFrame::HandleButtonPress(nsPresContext* aPresContext,
return false;
}
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::MainThreadScrollbarButtonClick);
if (!m) {
sb->MoveToNewPosition();
if (!weakFrame.IsAlive()) {

Просмотреть файл

@ -45,6 +45,7 @@
#include "mozilla/layers/APZCCallbackHelper.h"
#include "mozilla/layers/AsyncDragMetrics.h"
#include "mozilla/layers/InputAPZContext.h"
#include "mozilla/layers/ScrollInputMethods.h"
#include <algorithm>
using namespace mozilla;
@ -54,6 +55,7 @@ using mozilla::layers::AsyncDragMetrics;
using mozilla::layers::InputAPZContext;
using mozilla::layers::ScrollbarData;
using mozilla::layers::ScrollDirection;
using mozilla::layers::ScrollInputMethod;
bool nsSliderFrame::gMiddlePref = false;
int32_t nsSliderFrame::gSnapMultiplier;
@ -521,6 +523,10 @@ nsresult nsSliderFrame::HandleEvent(nsPresContext* aPresContext,
return NS_OK;
}
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::MainThreadScrollbarDrag);
// take our current position and subtract the start location
pos -= mDragStart;
bool isMouseOutsideThumb = false;
@ -587,6 +593,10 @@ nsresult nsSliderFrame::HandleEvent(nsPresContext* aPresContext,
nsSize thumbSize = thumbFrame->GetSize();
nscoord thumbLength = isHorizontal ? thumbSize.width : thumbSize.height;
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::MainThreadScrollbarTrackClick);
// set it
AutoWeakFrame weakFrame(this);
// should aMaySnap be true here?
@ -1290,6 +1300,10 @@ nsSliderFrame::HandlePress(nsPresContext* aPresContext, WidgetGUIEvent* aEvent,
return NS_OK;
}
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::MainThreadScrollbarTrackClick);
if (IsXULHorizontal() ? eventPoint.x < thumbRect.x
: eventPoint.y < thumbRect.y)
change = -1;

Просмотреть файл

@ -309,6 +309,11 @@ class AutoScrollChild extends JSWindowActorChild {
this._scrollErrorX = desiredScrollX - actualScrollX;
}
const kAutoscroll = 15; // defined in mozilla/layers/ScrollInputMethods.h
Services.telemetry
.getHistogramById("SCROLL_INPUT_METHODS")
.add(kAutoscroll);
this._scrollable.scrollBy({
left: actualScrollX,
top: actualScrollY,

Просмотреть файл

@ -13210,6 +13210,16 @@
"releaseChannelCollection": "opt-out",
"description": "Graphics Crash Reason (...)"
},
"SCROLL_INPUT_METHODS": {
"record_in_processes": ["main", "content", "gpu"],
"products": ["firefox"],
"alert_emails": ["kgupta@mozilla.com"],
"bug_numbers": [1670003],
"expires_in_version": "85",
"kind": "enumerated",
"n_values": 64,
"description": "Count of scroll actions triggered by different input methods. See gfx/layers/apz/util/ScrollInputMethods.h for a list of possible values and their meanings."
},
"WEBFONT_DOWNLOAD_TIME": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec"],

Просмотреть файл

@ -212,6 +212,7 @@
#include "mozilla/layers/APZInputBridge.h"
#include "mozilla/layers/InputAPZContext.h"
#include "mozilla/layers/KnowsCompositor.h"
#include "mozilla/layers/ScrollInputMethods.h"
#include "InputData.h"
#include "mozilla/Telemetry.h"
@ -7193,6 +7194,9 @@ bool nsWindow::OnGesture(WPARAM wParam, LPARAM lParam) {
bool endFeedback = true;
if (mGesture.PanDeltaToPixelScroll(wheelEvent)) {
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::SCROLL_INPUT_METHODS,
(uint32_t)ScrollInputMethod::MainThreadTouch);
DispatchEvent(&wheelEvent, status);
}