Commit e3b65800 authored by Sadrul Chowdhury's avatar Sadrul Chowdhury Committed by Commit Bot

[cc/metrics] Fix trace-event for reporters that don't produce a frame.

If a reporter is replaced by a new reporter, but the frame had not
produced a frame, then use the timestamp of the 'did not produce'
notification as the termination-time to end the trace-event, rather than
the time of the replacement.

BUG=none

Change-Id: I91ad6b9a1b0c31afe5309f89e7f8aaf43121e8eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2146517
Commit-Queue: Behdad Bakhshinategh <behdadb@chromium.org>
Reviewed-by: default avatarBehdad Bakhshinategh <behdadb@chromium.org>
Auto-Submit: Sadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758867}
parent 1acb35c3
......@@ -290,7 +290,7 @@ void CompositorFrameReporter::OnAbortBeginMainFrame(base::TimeTicks timestamp) {
}
void CompositorFrameReporter::OnDidNotProduceFrame() {
did_not_produce_frame_ = true;
did_not_produce_frame_time_ = base::TimeTicks::Now();
}
void CompositorFrameReporter::SetBlinkBreakdown(
......
......@@ -152,11 +152,17 @@ class CC_EXPORT CompositorFrameReporter {
void OnAbortBeginMainFrame(base::TimeTicks timestamp);
void OnDidNotProduceFrame();
bool did_finish_impl_frame() const { return did_finish_impl_frame_; }
bool did_not_produce_frame() const { return did_not_produce_frame_; }
base::TimeTicks impl_frame_finish_time() const {
return impl_frame_finish_time_;
}
bool did_not_produce_frame() const {
return did_not_produce_frame_time_.has_value();
}
base::TimeTicks did_not_produce_frame_time() const {
return *did_not_produce_frame_time_;
}
bool did_abort_main_frame() const {
return main_frame_abort_time_.has_value();
}
......@@ -236,13 +242,14 @@ class CC_EXPORT CompositorFrameReporter {
// Indicates if work on Impl frame is finished.
bool did_finish_impl_frame_ = false;
// Flag indicating if DidNotProduceFrame is called for this reporter
bool did_not_produce_frame_ = false;
// The time that work on Impl frame is finished. It's only valid if the
// reporter is in a stage other than begin impl frame.
base::TimeTicks impl_frame_finish_time_;
base::TimeTicks frame_deadline_;
// The timestamp of when the frame was marked as not having produced a frame
// (through a call to DidNotProduceFrame()).
base::Optional<base::TimeTicks> did_not_produce_frame_time_;
base::Optional<base::TimeTicks> main_frame_abort_time_;
};
} // namespace cc
......
......@@ -319,16 +319,18 @@ void CompositorFrameReportingController::AdvanceReporterStage(
PipelineStage target) {
auto& reporter = reporters_[target];
if (reporter) {
auto termination_time = (target == PipelineStage::kBeginMainFrame &&
reporter->did_abort_main_frame())
? reporter->main_frame_abort_time()
: Now();
if (reporters_[target]->did_not_produce_frame())
reporters_[target]->TerminateFrame(
FrameTerminationStatus::kDidNotProduceFrame, termination_time);
else
reporters_[target]->TerminateFrame(
FrameTerminationStatus::kReplacedByNewReporter, termination_time);
auto termination_status = FrameTerminationStatus::kReplacedByNewReporter;
base::TimeTicks termination_time;
if (reporter->did_not_produce_frame()) {
termination_time = reporter->did_not_produce_frame_time();
termination_status = FrameTerminationStatus::kDidNotProduceFrame;
} else if (target == PipelineStage::kBeginMainFrame &&
reporter->did_abort_main_frame()) {
termination_time = reporter->main_frame_abort_time();
} else {
termination_time = Now();
}
reporter->TerminateFrame(termination_status, termination_time);
}
reporters_[target] = std::move(reporters_[start]);
}
......
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