diff --git a/common_video/BUILD.gn b/common_video/BUILD.gn index a58141bbb3..b69c451d0d 100644 --- a/common_video/BUILD.gn +++ b/common_video/BUILD.gn @@ -52,6 +52,7 @@ rtc_static_library("common_video") { "../rtc_base:rtc_base", "../rtc_base:rtc_task_queue", "../rtc_base:safe_minmax", + "../system_wrappers:metrics", "//third_party/abseil-cpp/absl/types:optional", "//third_party/libyuv", ] diff --git a/common_video/video_render_frames.cc b/common_video/video_render_frames.cc index 376d8e01a0..5a0b0b0071 100644 --- a/common_video/video_render_frames.cc +++ b/common_video/video_render_frames.cc @@ -14,6 +14,7 @@ #include "rtc_base/logging.h" #include "rtc_base/timeutils.h" +#include "system_wrappers/include/metrics.h" namespace webrtc { namespace { @@ -37,7 +38,13 @@ uint32_t EnsureValidRenderDelay(uint32_t render_delay) { VideoRenderFrames::VideoRenderFrames(uint32_t render_delay_ms) : render_delay_ms_(EnsureValidRenderDelay(render_delay_ms)) {} -VideoRenderFrames::~VideoRenderFrames() = default; +VideoRenderFrames::~VideoRenderFrames() { + frames_dropped_ += incoming_frames_.size(); + RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.DroppedFrames.RenderQueue", + frames_dropped_); + RTC_LOG(LS_INFO) << "WebRTC.Video.DroppedFrames.RenderQueue " + << frames_dropped_; +} int32_t VideoRenderFrames::AddFrame(VideoFrame&& new_frame) { const int64_t time_now = rtc::TimeMillis(); @@ -47,12 +54,14 @@ int32_t VideoRenderFrames::AddFrame(VideoFrame&& new_frame) { if (!incoming_frames_.empty() && new_frame.render_time_ms() + kOldRenderTimestampMS < time_now) { RTC_LOG(LS_WARNING) << "Too old frame, timestamp=" << new_frame.timestamp(); + ++frames_dropped_; return -1; } if (new_frame.render_time_ms() > time_now + kFutureRenderTimestampMS) { RTC_LOG(LS_WARNING) << "Frame too long into the future, timestamp=" << new_frame.timestamp(); + ++frames_dropped_; return -1; } @@ -62,15 +71,17 @@ int32_t VideoRenderFrames::AddFrame(VideoFrame&& new_frame) { << ", latest=" << last_render_time_ms_; // For more details, see bug: // https://bugs.chromium.org/p/webrtc/issues/detail?id=7253 + ++frames_dropped_; return -1; } last_render_time_ms_ = new_frame.render_time_ms(); incoming_frames_.emplace_back(std::move(new_frame)); - if (incoming_frames_.size() > kMaxIncomingFramesBeforeLogged) + if (incoming_frames_.size() > kMaxIncomingFramesBeforeLogged) { RTC_LOG(LS_WARNING) << "Stored incoming frames: " << incoming_frames_.size(); + } return static_cast(incoming_frames_.size()); } @@ -78,6 +89,9 @@ absl::optional VideoRenderFrames::FrameToRender() { absl::optional render_frame; // Get the newest frame that can be released for rendering. while (!incoming_frames_.empty() && TimeToNextFrameRelease() <= 0) { + if (render_frame) { + ++frames_dropped_; + } render_frame = std::move(incoming_frames_.front()); incoming_frames_.pop_front(); } diff --git a/common_video/video_render_frames.h b/common_video/video_render_frames.h index 0b47e0a058..2226577dc3 100644 --- a/common_video/video_render_frames.h +++ b/common_video/video_render_frames.h @@ -46,6 +46,7 @@ class VideoRenderFrames { const uint32_t render_delay_ms_; int64_t last_render_time_ms_ = 0; + size_t frames_dropped_ = 0; }; } // namespace webrtc diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc index a80b5a593e..9839ed7a3b 100644 --- a/video/send_statistics_proxy.cc +++ b/video/send_statistics_proxy.cc @@ -502,7 +502,7 @@ void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms( RTC_HISTOGRAMS_PERCENTAGE( kIndex, uma_prefix_ + "SentPacketsLostInPercent", fraction_lost); log_stream << uma_prefix_ << "SentPacketsLostInPercent " - << fraction_lost; + << fraction_lost << "\n"; } // The RTCP packet type counters, delivered via the