Commit 68311b4b authored by Sadrul Habib Chowdhury's avatar Sadrul Habib Chowdhury Committed by Commit Bot

[cc/metrics] Fix trace-event for aborted frames.

If a 'begin main frame' is aborted (e.g. because of no visual damage),
then use the time of the abort as the termination time for the
trace-event, rather than when the reporter gets replaced by a new
reporter for the next frame, or when the scheduler drops the reporter
after the frame's deadline.

BUG=none

Change-Id: I4fdb32f8793eb7228439937759bdf12f0f3c0798
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2138963
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarBehdad Bakhshinategh <behdadb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757979}
parent b1dcb398
......@@ -224,6 +224,7 @@ CompositorFrameReporter::CopyReporterAtBeginImplStage() const {
should_report_metrics_);
new_reporter->did_finish_impl_frame_ = did_finish_impl_frame_;
new_reporter->impl_frame_finish_time_ = impl_frame_finish_time_;
new_reporter->main_frame_abort_time_ = main_frame_abort_time_;
new_reporter->current_stage_.stage_type =
StageType::kBeginImplFrameToSendBeginMainFrame;
new_reporter->current_stage_.start_time = stage_history_.front().start_time;
......@@ -281,9 +282,8 @@ void CompositorFrameReporter::OnFinishImplFrame(base::TimeTicks timestamp) {
}
void CompositorFrameReporter::OnAbortBeginMainFrame(base::TimeTicks timestamp) {
DCHECK(!did_abort_main_frame_);
did_abort_main_frame_ = true;
DCHECK(!main_frame_abort_time_.has_value());
main_frame_abort_time_ = timestamp;
impl_frame_finish_time_ = timestamp;
// impl_frame_finish_time_ can be used for the end of BeginMain to Commit
// stage
......
......@@ -9,6 +9,7 @@
#include <vector>
#include "base/containers/flat_set.h"
#include "base/optional.h"
#include "base/time/time.h"
#include "cc/base/base_export.h"
#include "cc/cc_export.h"
......@@ -151,12 +152,18 @@ class CC_EXPORT CompositorFrameReporter {
void OnAbortBeginMainFrame(base::TimeTicks timestamp);
void OnDidNotProduceFrame();
bool did_finish_impl_frame() const { return did_finish_impl_frame_; }
bool did_abort_main_frame() const { return did_abort_main_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_abort_main_frame() const {
return main_frame_abort_time_.has_value();
}
base::TimeTicks main_frame_abort_time() const {
return *main_frame_abort_time_;
}
private:
void DroppedFrame();
void MissedDeadlineFrame();
......@@ -229,14 +236,14 @@ class CC_EXPORT CompositorFrameReporter {
// Indicates if work on Impl frame is finished.
bool did_finish_impl_frame_ = false;
// Indicates if main frame is aborted after begin.
bool did_abort_main_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_;
base::Optional<base::TimeTicks> main_frame_abort_time_;
};
} // namespace cc
......
......@@ -312,13 +312,18 @@ void CompositorFrameReportingController::RemoveActiveTracker(
void CompositorFrameReportingController::AdvanceReporterStage(
PipelineStage start,
PipelineStage target) {
if (reporters_[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, Now());
FrameTerminationStatus::kDidNotProduceFrame, termination_time);
else
reporters_[target]->TerminateFrame(
FrameTerminationStatus::kReplacedByNewReporter, Now());
FrameTerminationStatus::kReplacedByNewReporter, 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