Commit 9d6e1dc2 authored by Steve Kobes's avatar Steve Kobes Committed by Commit Bot

Stop JankTracker when FrameView is disposed.

This prevents spurious trace events from the empty document created
before navigation begins.

Also annotate trace events with the frame they correspond to, combine
score and max distance into a single TracedValue, and change trace
category to "loading".

Bug: 581518
Change-Id: I9ee8005596245ad31c78a8556ec837e2ef999d24
Reviewed-on: https://chromium-review.googlesource.com/1101245Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Commit-Queue: Steve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567383}
parent e17dbaf1
...@@ -436,6 +436,7 @@ void LocalFrameView::Dispose() { ...@@ -436,6 +436,7 @@ void LocalFrameView::Dispose() {
ClearPrintContext(); ClearPrintContext();
ukm_time_aggregator_.reset(); ukm_time_aggregator_.reset();
jank_tracker_.Dispose();
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
has_been_disposed_ = true; has_been_disposed_ = true;
......
...@@ -133,7 +133,7 @@ void JankTracker::NotifyPrePaintFinished() { ...@@ -133,7 +133,7 @@ void JankTracker::NotifyPrePaintFinished() {
DVLOG(1) << "viewport " << (jank_fraction * 100) DVLOG(1) << "viewport " << (jank_fraction * 100)
<< "% janked, raising score to " << score_; << "% janked, raising score to " << score_;
TRACE_EVENT_INSTANT1("blink", "FrameLayoutJank", TRACE_EVENT_SCOPE_THREAD, TRACE_EVENT_INSTANT1("loading", "FrameLayoutJank", TRACE_EVENT_SCOPE_THREAD,
"viewportFraction", jank_fraction); "viewportFraction", jank_fraction);
region_ = Region(); region_ = Region();
...@@ -153,6 +153,13 @@ bool JankTracker::IsActive() { ...@@ -153,6 +153,13 @@ bool JankTracker::IsActive() {
return true; return true;
} }
std::unique_ptr<TracedValue> JankTracker::TraceData() const {
std::unique_ptr<TracedValue> value = TracedValue::Create();
value->SetDouble("score", score_);
value->SetDouble("maxDistance", max_distance_);
return value;
}
void JankTracker::TimerFired(TimerBase* timer) { void JankTracker::TimerFired(TimerBase* timer) {
has_fired_ = true; has_fired_ = true;
...@@ -165,8 +172,9 @@ void JankTracker::TimerFired(TimerBase* timer) { ...@@ -165,8 +172,9 @@ void JankTracker::TimerFired(TimerBase* timer) {
<< " is " << score_ << " with max move distance of " << " is " << score_ << " with max move distance of "
<< max_distance_; << max_distance_;
TRACE_EVENT_INSTANT2("blink", "TotalLayoutJank", TRACE_EVENT_SCOPE_THREAD, TRACE_EVENT_INSTANT2("loading", "TotalLayoutJank", TRACE_EVENT_SCOPE_THREAD,
"score", score_, "maxDistance", max_distance_); "data", TraceData(), "frame",
ToTraceValue(&frame_view_->GetFrame()));
} }
} // namespace blink } // namespace blink
...@@ -16,6 +16,7 @@ class LayoutObject; ...@@ -16,6 +16,7 @@ class LayoutObject;
class LayoutRect; class LayoutRect;
class LocalFrameView; class LocalFrameView;
class PaintLayer; class PaintLayer;
class TracedValue;
// Tracks "jank" from layout objects changing their visual location between // Tracks "jank" from layout objects changing their visual location between
// animation frames. // animation frames.
...@@ -32,9 +33,11 @@ class CORE_EXPORT JankTracker { ...@@ -32,9 +33,11 @@ class CORE_EXPORT JankTracker {
bool IsActive(); bool IsActive();
double Score() const { return score_; } double Score() const { return score_; }
float MaxDistance() const { return max_distance_; } float MaxDistance() const { return max_distance_; }
void Dispose() { timer_.Stop(); }
private: private:
void TimerFired(TimerBase*); void TimerFired(TimerBase*);
std::unique_ptr<TracedValue> TraceData() const;
// This owns us. // This owns us.
UntracedMember<LocalFrameView> frame_view_; UntracedMember<LocalFrameView> frame_view_;
......
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