Commit a2eeadee authored by Steve Kobes's avatar Steve Kobes Committed by Chromium LUCI CQ

Make LayoutShiftTracker verbose logging available to non-debug builds.

These logs can now be viewed on official release builds with the flags:
  --enable-logging=stderr --vmodule=layout_shift*=1

This will make it easier to debug CLS issues for folks who may not have
a Chromium checkout handy.

Change-Id: Ic273684711b3dfd4e34827eca8cfe4deda744d48
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2568351
Commit-Queue: Steve Kobes <skobes@chromium.org>
Reviewed-by: default avatarNicolás Peña Moreno <npm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832544}
parent a2a7e93a
...@@ -125,12 +125,14 @@ void RegionToTracedValue(const LayoutShiftRegion& region, TracedValue& value) { ...@@ -125,12 +125,14 @@ void RegionToTracedValue(const LayoutShiftRegion& region, TracedValue& value) {
value.EndArray(); value.EndArray();
} }
#if DCHECK_IS_ON()
bool ShouldLog(const LocalFrame& frame) { bool ShouldLog(const LocalFrame& frame) {
if (!VLOG_IS_ON(1))
return false;
DCHECK(frame.GetDocument());
const String& url = frame.GetDocument()->Url().GetString(); const String& url = frame.GetDocument()->Url().GetString();
return !url.StartsWith("devtools:"); return !url.StartsWith("devtools:");
} }
#endif
} // namespace } // namespace
...@@ -263,21 +265,19 @@ void LayoutShiftTracker::ObjectShifted( ...@@ -263,21 +265,19 @@ void LayoutShiftTracker::ObjectShifted(
GetMoveDistance(old_starting_point_in_root, new_starting_point_in_root); GetMoveDistance(old_starting_point_in_root, new_starting_point_in_root);
frame_max_distance_ = std::max(frame_max_distance_, move_distance); frame_max_distance_ = std::max(frame_max_distance_, move_distance);
#if DCHECK_IS_ON()
LocalFrame& frame = frame_view_->GetFrame(); LocalFrame& frame = frame_view_->GetFrame();
if (ShouldLog(frame)) { if (ShouldLog(frame)) {
DVLOG(2) << "in " << (frame.IsMainFrame() ? "" : "subframe ") VLOG(1) << "in " << (frame.IsMainFrame() ? "" : "subframe ")
<< frame.GetDocument()->Url() << ", " << object << " moved from " << frame.GetDocument()->Url() << ", " << object << " moved from "
<< old_rect_in_root << " to " << new_rect_in_root << old_rect_in_root << " to " << new_rect_in_root
<< " (visible from " << visible_old_rect << " to " << " (visible from " << visible_old_rect << " to "
<< visible_new_rect << ")"; << visible_new_rect << ")";
if (old_starting_point_in_root != old_rect_in_root.Location() || if (old_starting_point_in_root != old_rect_in_root.Location() ||
new_starting_point_in_root != new_rect_in_root.Location()) { new_starting_point_in_root != new_rect_in_root.Location()) {
DVLOG(2) << " (starting point from " << old_starting_point_in_root VLOG(1) << " (starting point from " << old_starting_point_in_root
<< " to " << new_starting_point_in_root << ")"; << " to " << new_starting_point_in_root << ")";
} }
} }
#endif
region_.AddRect(visible_old_rect); region_.AddRect(visible_old_rect);
region_.AddRect(visible_new_rect); region_.AddRect(visible_new_rect);
...@@ -438,15 +438,13 @@ void LayoutShiftTracker::NotifyPrePaintFinished() { ...@@ -438,15 +438,13 @@ void LayoutShiftTracker::NotifyPrePaintFinished() {
overall_max_distance_ = std::max(overall_max_distance_, frame_max_distance_); overall_max_distance_ = std::max(overall_max_distance_, frame_max_distance_);
#if DCHECK_IS_ON()
LocalFrame& frame = frame_view_->GetFrame(); LocalFrame& frame = frame_view_->GetFrame();
if (ShouldLog(frame)) { if (ShouldLog(frame)) {
DVLOG(1) << "in " << (frame.IsMainFrame() ? "" : "subframe ") VLOG(1) << "in " << (frame.IsMainFrame() ? "" : "subframe ")
<< frame.GetDocument()->Url() << ", viewport was " << frame.GetDocument()->Url() << ", viewport was "
<< (impact_fraction * 100) << "% impacted with distance fraction " << (impact_fraction * 100) << "% impacted with distance fraction "
<< move_distance_factor; << move_distance_factor;
} }
#endif
if (pointerdown_pending_data_.saw_pointerdown) { if (pointerdown_pending_data_.saw_pointerdown) {
pointerdown_pending_data_.score_delta += score_delta; pointerdown_pending_data_.score_delta += score_delta;
...@@ -517,15 +515,13 @@ void LayoutShiftTracker::ReportShift(double score_delta, ...@@ -517,15 +515,13 @@ void LayoutShiftTracker::ReportShift(double score_delta,
"data", PerFrameTraceData(score_delta, had_recent_input), "data", PerFrameTraceData(score_delta, had_recent_input),
"frame", ToTraceValue(&frame)); "frame", ToTraceValue(&frame));
#if DCHECK_IS_ON()
if (ShouldLog(frame)) { if (ShouldLog(frame)) {
DVLOG(1) << "in " << (frame.IsMainFrame() ? "" : "subframe ") VLOG(1) << "in " << (frame.IsMainFrame() ? "" : "subframe ")
<< frame.GetDocument()->Url().GetString() << ", layout shift of " << frame.GetDocument()->Url().GetString() << ", layout shift of "
<< score_delta << score_delta
<< (had_recent_input ? " excluded by recent input" : " reported") << (had_recent_input ? " excluded by recent input" : " reported")
<< "; cumulative score is " << score_; << "; cumulative score is " << score_;
} }
#endif
} }
void LayoutShiftTracker::NotifyInput(const WebInputEvent& event) { void LayoutShiftTracker::NotifyInput(const WebInputEvent& event) {
......
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