ZeroHertz: expose time to first frame statistic.
Bug: chromium:1324120 Change-Id: Ie609da309427ca5d2ff8585a8dc730586553c725 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/262247 Auto-Submit: Markus Handell <handellm@webrtc.org> Commit-Queue: Markus Handell <handellm@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36867}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
1cb0b90df4
commit
9d04a78f73
@ -305,6 +305,7 @@ rtc_library("frame_cadence_adapter") {
|
|||||||
"../api:sequence_checker",
|
"../api:sequence_checker",
|
||||||
"../api/task_queue",
|
"../api/task_queue",
|
||||||
"../api/units:time_delta",
|
"../api/units:time_delta",
|
||||||
|
"../api/units:timestamp",
|
||||||
"../api/video:video_frame",
|
"../api/video:video_frame",
|
||||||
"../rtc_base:checks",
|
"../rtc_base:checks",
|
||||||
"../rtc_base:logging",
|
"../rtc_base:logging",
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
#include "api/sequence_checker.h"
|
#include "api/sequence_checker.h"
|
||||||
#include "api/task_queue/task_queue_base.h"
|
#include "api/task_queue/task_queue_base.h"
|
||||||
#include "api/units/time_delta.h"
|
#include "api/units/time_delta.h"
|
||||||
|
#include "api/units/timestamp.h"
|
||||||
#include "api/video/video_frame.h"
|
#include "api/video/video_frame.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
@ -184,6 +185,7 @@ class ZeroHertzAdapterMode : public AdapterMode {
|
|||||||
TaskQueueBase* const queue_;
|
TaskQueueBase* const queue_;
|
||||||
Clock* const clock_;
|
Clock* const clock_;
|
||||||
FrameCadenceAdapterInterface::Callback* const callback_;
|
FrameCadenceAdapterInterface::Callback* const callback_;
|
||||||
|
|
||||||
// The configured max_fps.
|
// The configured max_fps.
|
||||||
// TODO(crbug.com/1255737): support max_fps updates.
|
// TODO(crbug.com/1255737): support max_fps updates.
|
||||||
const double max_fps_;
|
const double max_fps_;
|
||||||
@ -264,6 +266,10 @@ class FrameCadenceAdapterImpl : public FrameCadenceAdapterInterface {
|
|||||||
// Cache for the current adapter mode.
|
// Cache for the current adapter mode.
|
||||||
AdapterMode* current_adapter_mode_ = nullptr;
|
AdapterMode* current_adapter_mode_ = nullptr;
|
||||||
|
|
||||||
|
// Timestamp for statistics reporting.
|
||||||
|
absl::optional<Timestamp> zero_hertz_adapter_created_timestamp_
|
||||||
|
RTC_GUARDED_BY(queue_);
|
||||||
|
|
||||||
// Set up during Initialize.
|
// Set up during Initialize.
|
||||||
Callback* callback_ = nullptr;
|
Callback* callback_ = nullptr;
|
||||||
|
|
||||||
@ -619,6 +625,15 @@ void FrameCadenceAdapterImpl::OnFrame(const VideoFrame& frame) {
|
|||||||
frames_scheduled_for_processing_.fetch_add(1, std::memory_order_relaxed);
|
frames_scheduled_for_processing_.fetch_add(1, std::memory_order_relaxed);
|
||||||
queue_->PostTask(ToQueuedTask(safety_.flag(), [this, post_time, frame] {
|
queue_->PostTask(ToQueuedTask(safety_.flag(), [this, post_time, frame] {
|
||||||
RTC_DCHECK_RUN_ON(queue_);
|
RTC_DCHECK_RUN_ON(queue_);
|
||||||
|
if (zero_hertz_adapter_created_timestamp_.has_value()) {
|
||||||
|
TimeDelta time_until_first_frame =
|
||||||
|
clock_->CurrentTime() - *zero_hertz_adapter_created_timestamp_;
|
||||||
|
zero_hertz_adapter_created_timestamp_ = absl::nullopt;
|
||||||
|
RTC_HISTOGRAM_COUNTS_10000(
|
||||||
|
"WebRTC.Screenshare.ZeroHz.TimeUntilFirstFrameMs",
|
||||||
|
time_until_first_frame.ms());
|
||||||
|
}
|
||||||
|
|
||||||
const int frames_scheduled_for_processing =
|
const int frames_scheduled_for_processing =
|
||||||
frames_scheduled_for_processing_.fetch_sub(1,
|
frames_scheduled_for_processing_.fetch_sub(1,
|
||||||
std::memory_order_relaxed);
|
std::memory_order_relaxed);
|
||||||
@ -673,6 +688,7 @@ void FrameCadenceAdapterImpl::MaybeReconfigureAdapters(
|
|||||||
should_request_refresh_frame_ = false;
|
should_request_refresh_frame_ = false;
|
||||||
callback_->RequestRefreshFrame();
|
callback_->RequestRefreshFrame();
|
||||||
}
|
}
|
||||||
|
zero_hertz_adapter_created_timestamp_ = clock_->CurrentTime();
|
||||||
}
|
}
|
||||||
zero_hertz_adapter_->ReconfigureParameters(zero_hertz_params_.value());
|
zero_hertz_adapter_->ReconfigureParameters(zero_hertz_params_.value());
|
||||||
current_adapter_mode_ = &zero_hertz_adapter_.value();
|
current_adapter_mode_ = &zero_hertz_adapter_.value();
|
||||||
|
|||||||
@ -902,6 +902,22 @@ TEST_F(FrameCadenceAdapterMetricsTest, RecordsMinLtMaxConstraintIfSetOnFrame) {
|
|||||||
ElementsAre(Pair(60 * 4.0 + 5.0 - 1, 1)));
|
ElementsAre(Pair(60 * 4.0 + 5.0 - 1, 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(FrameCadenceAdapterMetricsTest, RecordsTimeUntilFirstFrame) {
|
||||||
|
MockCallback callback;
|
||||||
|
test::ScopedKeyValueConfig no_field_trials;
|
||||||
|
auto adapter = CreateAdapter(no_field_trials, time_controller_.GetClock());
|
||||||
|
adapter->Initialize(&callback);
|
||||||
|
adapter->SetZeroHertzModeEnabled(
|
||||||
|
FrameCadenceAdapterInterface::ZeroHertzModeParams{});
|
||||||
|
adapter->OnConstraintsChanged(VideoTrackSourceConstraints{0, 5.0});
|
||||||
|
time_controller_.AdvanceTime(TimeDelta::Millis(666));
|
||||||
|
adapter->OnFrame(CreateFrame());
|
||||||
|
DepleteTaskQueues();
|
||||||
|
EXPECT_THAT(
|
||||||
|
metrics::Samples("WebRTC.Screenshare.ZeroHz.TimeUntilFirstFrameMs"),
|
||||||
|
ElementsAre(Pair(666, 1)));
|
||||||
|
}
|
||||||
|
|
||||||
TEST(FrameCadenceAdapterRealTimeTest, TimestampsDoNotDrift) {
|
TEST(FrameCadenceAdapterRealTimeTest, TimestampsDoNotDrift) {
|
||||||
// This regression test must be performed in realtime because of limitations
|
// This regression test must be performed in realtime because of limitations
|
||||||
// in GlobalSimulatedTimeController.
|
// in GlobalSimulatedTimeController.
|
||||||
|
|||||||
Reference in New Issue
Block a user