[tracing] Add higher-level LatencyInfo.Flow events in RenderInputRouter
This change adds LatencyInfo.flow events to RenderInputRouter::ForwardGestureEventWithLatencyInfo and RenderInputRouter::ForwardTouchEventWithLatencyInfo to get fuller work coverage. Low-Coverage-Reason: TESTS_IN_SEPARATE_CL Bug: b:356584965 Change-Id: If5b1f52d0190b5bce9c85610bfd41a5ea4dd2d65 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5766653 Commit-Queue: Oksana Zhuravlova <oksamyt@chromium.org> Reviewed-by: Alexander Timin <altimin@chromium.org> Reviewed-by: Robert Flack <flackr@chromium.org> Reviewed-by: Tushar Agarwal <agarwaltushar@google.com> Cr-Commit-Position: refs/heads/main@{#1352858}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
561a14bf24
commit
7cfc830947
@ -320,6 +320,18 @@ void RenderInputRouter::ForwardGestureEventWithLatencyInfo(
|
||||
TRACE_EVENT1("input", "RenderInputRouter::ForwardGestureEvent", "type",
|
||||
WebInputEvent::GetName(gesture_event.GetType()));
|
||||
|
||||
input::GestureEventWithLatencyInfo gesture_with_latency(gesture_event,
|
||||
latency_info);
|
||||
|
||||
// Assigns a `trace_id` to the latency object.
|
||||
latency_tracker_->OnEventStart(&gesture_with_latency.latency);
|
||||
|
||||
TRACE_EVENT("input,benchmark,latencyInfo", "LatencyInfo.Flow",
|
||||
[&gesture_with_latency](perfetto::EventContext ctx) {
|
||||
ui::LatencyInfo::FillTraceEvent(gesture_with_latency.latency,
|
||||
ctx);
|
||||
});
|
||||
|
||||
// Early out if necessary, prior to performing latency logic.
|
||||
if (delegate_->IsIgnoringWebInputEvents(gesture_event)) {
|
||||
// IgnoreWebInputEvents is primarily concerned with suppressing event
|
||||
@ -360,8 +372,6 @@ void RenderInputRouter::ForwardGestureEventWithLatencyInfo(
|
||||
return;
|
||||
}
|
||||
|
||||
input::GestureEventWithLatencyInfo gesture_with_latency(gesture_event,
|
||||
latency_info);
|
||||
DispatchInputEventWithLatencyInfo(
|
||||
gesture_with_latency.event, &gesture_with_latency.latency,
|
||||
&gesture_with_latency.event.GetModifiableEventLatencyMetadata());
|
||||
@ -450,6 +460,16 @@ void RenderInputRouter::ForwardTouchEventWithLatencyInfo(
|
||||
// ignored if appropriate in FilterInputEvent().
|
||||
|
||||
input::TouchEventWithLatencyInfo touch_with_latency(touch_event, latency);
|
||||
|
||||
// Assigns a `trace_id` to the latency object.
|
||||
latency_tracker_->OnEventStart(&touch_with_latency.latency);
|
||||
|
||||
TRACE_EVENT("input,benchmark,latencyInfo", "LatencyInfo.Flow",
|
||||
[&touch_with_latency](perfetto::EventContext ctx) {
|
||||
ui::LatencyInfo::FillTraceEvent(touch_with_latency.latency,
|
||||
ctx);
|
||||
});
|
||||
|
||||
DispatchInputEventWithLatencyInfo(
|
||||
touch_with_latency.event, &touch_with_latency.latency,
|
||||
&touch_with_latency.event.GetModifiableEventLatencyMetadata());
|
||||
|
@ -214,8 +214,10 @@ void RenderInputRouterLatencyTracker::OnInputEventAck(
|
||||
}
|
||||
|
||||
void RenderInputRouterLatencyTracker::OnEventStart(ui::LatencyInfo* latency) {
|
||||
static uint64_t global_trace_id = 0;
|
||||
latency->set_trace_id(++global_trace_id);
|
||||
if (latency->trace_id() == -1) {
|
||||
static uint64_t global_trace_id = 0;
|
||||
latency->set_trace_id(++global_trace_id);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace input
|
||||
|
@ -31,6 +31,9 @@ class COMPONENT_EXPORT(INPUT) RenderInputRouterLatencyTracker {
|
||||
|
||||
virtual ~RenderInputRouterLatencyTracker();
|
||||
|
||||
// Sets `latency`'s `trace_id` field to the next global ID.
|
||||
void OnEventStart(ui::LatencyInfo* latency);
|
||||
|
||||
// Populates the LatencyInfo with relevant entries for latency tracking.
|
||||
// Called when an event is received by the RenderWidgetHost, prior to
|
||||
// that event being forwarded to the renderer (via the InputRouter).
|
||||
@ -49,11 +52,9 @@ class COMPONENT_EXPORT(INPUT) RenderInputRouterLatencyTracker {
|
||||
void reset_delegate() { render_input_router_delegate_ = nullptr; }
|
||||
|
||||
private:
|
||||
void OnEventStart(ui::LatencyInfo* latency);
|
||||
|
||||
bool has_seen_first_gesture_scroll_update_;
|
||||
int64_t gesture_scroll_id_;
|
||||
int64_t touch_trace_id_;
|
||||
bool has_seen_first_gesture_scroll_update_ = false;
|
||||
int64_t gesture_scroll_id_ = -1;
|
||||
int64_t touch_trace_id_ = -1;
|
||||
|
||||
// Whether the current stream of touch events includes more than one active
|
||||
// touch point. This is set in OnInputEvent, and cleared in OnInputEventAck.
|
||||
|
@ -122,6 +122,17 @@ void LatencyInfo::TraceIntermediateFlowEvents(
|
||||
}
|
||||
}
|
||||
|
||||
void LatencyInfo::FillTraceEvent(const LatencyInfo& latency,
|
||||
const perfetto::EventContext& ctx) {
|
||||
perfetto::protos::pbzero::ChromeLatencyInfo* info =
|
||||
ctx.event()->set_chrome_latency_info();
|
||||
info->set_trace_id(latency.trace_id());
|
||||
|
||||
tracing::FillFlowEvent(
|
||||
ctx, perfetto::protos::pbzero::TrackEvent::LegacyEvent::FLOW_OUT,
|
||||
latency.trace_id());
|
||||
}
|
||||
|
||||
void LatencyInfo::AddNewLatencyFrom(const LatencyInfo& other) {
|
||||
// Don't clobber an existing trace_id_.
|
||||
if (trace_id_ == -1) {
|
||||
@ -199,8 +210,8 @@ void LatencyInfo::AddLatencyNumberWithTimestampImpl(
|
||||
ctx.event<perfetto::protos::pbzero::ChromeTrackEvent>()
|
||||
->set_chrome_latency_info();
|
||||
info->set_trace_id(trace_id_);
|
||||
tracing::FillFlowEvent(ctx, TrackEvent::LegacyEvent::FLOW_OUT,
|
||||
trace_id_);
|
||||
tracing::FillFlowEvent(
|
||||
ctx, TrackEvent::LegacyEvent::FLOW_INOUT, trace_id_);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "base/time/time.h"
|
||||
#include "build/blink_buildflags.h"
|
||||
#include "build/build_config.h"
|
||||
#include "services/tracing/public/cpp/perfetto/flow_event_utils.h"
|
||||
#include "third_party/perfetto/protos/perfetto/trace/track_event/chrome_latency_info.pbzero.h"
|
||||
|
||||
#if BUILDFLAG(USE_BLINK)
|
||||
@ -103,6 +104,11 @@ class LatencyInfo {
|
||||
const std::vector<LatencyInfo>& latency_info,
|
||||
perfetto::protos::pbzero::ChromeLatencyInfo::Step step);
|
||||
|
||||
// Populates fields for a `LatencyInfo.Flow` event with `ctx`
|
||||
// from `latency`.
|
||||
static void FillTraceEvent(const LatencyInfo& latency,
|
||||
const perfetto::EventContext& ctx);
|
||||
|
||||
// Add timestamps for components that are in |other| but not in |this|.
|
||||
void AddNewLatencyFrom(const LatencyInfo& other);
|
||||
|
||||
|
Reference in New Issue
Block a user