autotest: Add a time out to stopSmoothnessTracking
ThroughputTracker::Stop does not invoke the report callback when
gpu-process crashes and no valid data to report. Start a timer
to clean up old tracker and report an error error. This make
tests fail faster and error is limited to just the one with
gpu-process crash.
Bug: b/196856854
Change-Id: I67a45478cca99f6cb31ff32dcbfe572cccc4d0f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3179815
Reviewed-by: Achuith Bhandarkar <[email protected]>
Commit-Queue: Xiyuan Xia <[email protected]>
Cr-Commit-Position: refs/heads/main@{#924534}
diff --git a/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc b/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc
index 47575d6..7f153f6f 100644
--- a/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc
+++ b/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc
@@ -5038,6 +5038,14 @@
base::NumberToString(display_id)})));
}
+ // ThroughputTracker::Stop does not invoke the report callback when
+ // gpu-process crashes and has no valid data to report. Start a timer to
+ // handle this case.
+ timeout_timer_.Start(
+ FROM_HERE, base::TimeDelta::FromSeconds(5),
+ base::BindOnce(&AutotestPrivateStopSmoothnessTrackingFunction::OnTimeOut,
+ this, display_id));
+
it->second.callback = base::BindOnce(
&AutotestPrivateStopSmoothnessTrackingFunction::OnReportData, this);
it->second.stopping = true;
@@ -5048,6 +5056,11 @@
void AutotestPrivateStopSmoothnessTrackingFunction::OnReportData(
const cc::FrameSequenceMetrics::CustomReportData& data) {
+ if (did_respond())
+ return;
+
+ timeout_timer_.AbandonAndStop();
+
api::autotest_private::ThroughputTrackerAnimationData result_data;
result_data.frames_expected = data.frames_expected;
result_data.frames_produced = data.frames_produced;
@@ -5058,6 +5071,21 @@
result_data)));
}
+void AutotestPrivateStopSmoothnessTrackingFunction::OnTimeOut(
+ int64_t display_id) {
+ if (did_respond())
+ return;
+
+ // Clean up the non-functional tracker.
+ auto* infos = GetDisplaySmoothnessTrackerInfos();
+ auto it = infos->find(display_id);
+ if (it == infos->end())
+ return;
+ infos->erase(it);
+
+ Respond(Error("Smoothness is not available"));
+}
+
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateWaitForAmbientPhotoAnimationFunction
//////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.h b/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.h
index db3be91e..ea76e98 100644
--- a/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.h
+++ b/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.h
@@ -1347,6 +1347,9 @@
ResponseAction Run() override;
void OnReportData(const cc::FrameSequenceMetrics::CustomReportData& data);
+ void OnTimeOut(int64_t display_id);
+
+ base::OneShotTimer timeout_timer_;
};
class AutotestPrivateWaitForAmbientPhotoAnimationFunction