Bug 1500465 - Measure touch scroll latency and connect to telemetry. r=mstange,botond

Differential Revision: https://phabricator.services.mozilla.com/D36246

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Sean Feng 2019-12-07 03:57:56 +00:00
Родитель 4cd0658446
Коммит 6db9bbdc3e
7 изменённых файлов: 68 добавлений и 1 удалений

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

@ -2324,6 +2324,10 @@ void RecordCompositionPayloadsPresented(
Telemetry::AccumulateTimeDelta(
mozilla::Telemetry::KEYPRESS_PRESENT_LATENCY, payload.mTimeStamp,
presented);
} else if (payload.mType == CompositionPayloadType::eAPZScroll) {
Telemetry::AccumulateTimeDelta(
mozilla::Telemetry::SCROLL_PRESENT_LATENCY, payload.mTimeStamp,
presented);
}
}
}

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

@ -95,6 +95,8 @@ class APZSampler {
const LayerMetricsWrapper& aLayer);
AsyncTransformComponentMatrix GetCurrentAsyncTransformWithOverscroll(
const LayerMetricsWrapper& aLayer);
Maybe<CompositionPayload> NotifyScrollSampling(
const LayerMetricsWrapper& aLayer);
void MarkAsyncTransformAppliedToContent(const LayerMetricsWrapper& aLayer);
bool HasUnusedAsyncTransform(const LayerMetricsWrapper& aLayer);

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

@ -162,6 +162,14 @@ AsyncTransform APZSampler::GetCurrentAsyncTransform(
AsyncPanZoomController::eForCompositing, aComponents);
}
Maybe<CompositionPayload> APZSampler::NotifyScrollSampling(
const LayerMetricsWrapper& aLayer) {
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
AssertOnSamplerThread();
MOZ_ASSERT(aLayer.GetApzc());
return aLayer.GetApzc()->NotifyScrollSampling();
}
AsyncTransformComponentMatrix APZSampler::GetOverscrollTransform(
const LayerMetricsWrapper& aLayer) {
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());

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

@ -1997,6 +1997,7 @@ nsEventStatus AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent) {
bool scrollSnapped =
MaybeAdjustDestinationForScrollSnapping(aEvent, destination);
RecordScrollPayload(aEvent.mTimeStamp);
// If smooth scrolling is disabled, then scroll immediately to the destination
if (!StaticPrefs::general_smoothScroll()) {
CancelAnimation();
@ -2378,6 +2379,7 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel(
distance, ScrollSource::Wheel);
ParentLayerPoint startPoint = aEvent.mLocalOrigin;
ParentLayerPoint endPoint = aEvent.mLocalOrigin - delta;
RecordScrollPayload(aEvent.mTimeStamp);
CallDispatchScroll(startPoint, endPoint, handoffState);
SetState(NOTHING);
@ -2396,6 +2398,7 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel(
// update it.
RecursiveMutexAutoLock lock(mRecursiveMutex);
RecordScrollPayload(aEvent.mTimeStamp);
// Perform scroll snapping if appropriate.
CSSPoint startPosition = Metrics().GetScrollOffset();
// If we're already in a wheel scroll or smooth scroll animation,
@ -2621,6 +2624,7 @@ nsEventStatus AsyncPanZoomController::OnPan(const PanGestureInput& aEvent,
ParentLayerPoint startPoint = aEvent.mLocalPanStartPoint;
ParentLayerPoint endPoint =
aEvent.mLocalPanStartPoint - logicalPanDisplacement;
RecordScrollPayload(aEvent.mTimeStamp);
CallDispatchScroll(startPoint, endPoint, handoffState);
return nsEventStatus_eConsumeNoDefault;
@ -3129,6 +3133,15 @@ void AsyncPanZoomController::UpdateWithTouchAtDevicePoint(
mY.UpdateWithTouchAtDevicePoint(point.y, aEvent.mTime);
}
Maybe<CompositionPayload> AsyncPanZoomController::NotifyScrollSampling() {
if (StaticPrefs::apz_frame_delay_enabled()) {
return std::move(mCompositedScrollPayload);
}
// If frame.delay disabled, the triggering events are those
// from the most recent frame
return std::move(mScrollPayload);
}
bool AsyncPanZoomController::AttemptScroll(
ParentLayerPoint& aStartPoint, ParentLayerPoint& aEndPoint,
OverscrollHandoffState& aOverscrollHandoffState) {
@ -3494,6 +3507,13 @@ void AsyncPanZoomController::CallDispatchScroll(
aOverscrollHandoffState);
}
void AsyncPanZoomController::RecordScrollPayload(const TimeStamp& aTimeStamp) {
if (!mScrollPayload) {
mScrollPayload = Some(
CompositionPayload{CompositionPayloadType::eAPZScroll, aTimeStamp});
}
}
void AsyncPanZoomController::TrackTouch(const MultiTouchInput& aEvent) {
ExternalPoint extPoint = GetFirstExternalTouchPoint(aEvent);
ScreenPoint panVector = PanVector(extPoint);
@ -3508,6 +3528,7 @@ void AsyncPanZoomController::TrackTouch(const MultiTouchInput& aEvent) {
OverscrollHandoffState handoffState(
*GetCurrentTouchBlock()->GetOverscrollHandoffChain(), panVector,
ScrollSource::Touch);
RecordScrollPayload(aEvent.mTimeStamp);
CallDispatchScroll(prevTouchPoint, touchPoint, handoffState);
}
}
@ -4208,6 +4229,10 @@ bool AsyncPanZoomController::SampleCompositedAsyncTransform() {
mCompositedLayoutViewport = Metrics().GetLayoutViewport();
mCompositedScrollOffset = Metrics().GetScrollOffset();
mCompositedZoom = Metrics().GetZoom();
// If frame.delay enabled, we pass along the scroll events from
// frame before since they were what moved the items on the layer
mCompositedScrollPayload = std::move(mScrollPayload);
return true;
}
return false;

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

@ -1044,9 +1044,14 @@ class AsyncPanZoomController {
// Position on screen where user first put their finger down.
ExternalPoint mStartTouch;
Maybe<CompositionPayload> mCompositedScrollPayload;
Maybe<CompositionPayload> mScrollPayload;
friend class Axis;
public:
Maybe<CompositionPayload> NotifyScrollSampling();
/**
* Invoke |callable|, passing |mLastContentPaintMetrics| as argument,
* while holding the APZC lock required to access |mLastContentPaintMetrics|.
@ -1502,6 +1507,8 @@ class AsyncPanZoomController {
ParentLayerPoint& aEndPoint,
OverscrollHandoffState& aOverscrollHandoffState);
void RecordScrollPayload(const TimeStamp& aTimeStamp);
/**
* A helper function for overscrolling during panning. This is a wrapper
* around OverscrollBy() that also implements restrictions on entering

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

@ -1021,10 +1021,18 @@ bool AsyncCompositionManager::ApplyAsyncContentTransformToTree(
sampler->GetGuid(*zoomedMetrics) == sampler->GetGuid(wrapper))
? AsyncTransformComponents{AsyncTransformComponent::eLayout}
: LayoutAndVisual;
AsyncTransform asyncTransformWithoutOverscroll =
sampler->GetCurrentAsyncTransform(wrapper,
asyncTransformComponents);
Maybe<CompositionPayload> payload =
sampler->NotifyScrollSampling(wrapper);
// The scroll latency should be measured between composition and the
// first scrolling event. Otherwise we observe metrics with <16ms
// latency even when frame.delay is enabled.
if (payload.isSome()) {
mLayerManager->RegisterPayload(*payload);
}
AsyncTransformComponentMatrix overscrollTransform =
sampler->GetOverscrollTransform(wrapper);
AsyncTransformComponentMatrix asyncTransform =

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

@ -1710,6 +1710,19 @@
"description": "Time between receiving a keypress event on the event loop and compositing its result onto the screen (ms)",
"bug_numbers": [1506537, 1580077]
},
"SCROLL_PRESENT_LATENCY": {
"record_in_processes": ["main", "gpu"],
"products": ["firefox", "fennec", "geckoview"],
"alert_emails": [ "perfteam@mozilla.com", "sefeng@mozilla.com", "vchin@mozilla.com" ],
"expires_in_version": "never",
"kind": "exponential",
"releaseChannelCollection": "opt-out",
"low": 1,
"high": 20000,
"n_buckets": 100,
"description": "Time between receiving a scroll event on the event loop and compositing its result onto the screen (ms)",
"bug_numbers": [ 1500465 ]
},
"CANVAS_2D_USED": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec", "geckoview"],