tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 4b76742ffa159e4d26282195dbf1f4acd5959ab1
parent b1994724aafb3d09ff1c6eb8796374b13753ea1c
Author: Dan Baker <dbaker@mozilla.com>
Date:   Mon, 27 Oct 2025 14:09:34 -0600

Bug 1995393 - Vendor libwebrtc from f633ab4d21

Upstream commit: https://webrtc.googlesource.com/src/+/f633ab4d210ac9897f6c25455ea77467bc4611f6
    Remove usage of RateTracker in ReceiveStatisticsProxy

    To reduce usage of global time functions: RateTracker relies on global clock, replacement code uses injected clock.

    This usage of RateTracker queries only total rate which doesn't need
    bucketing feature of RateTracker and can be implemented with a simple counter.

    Bug: webrtc:42223992
    Change-Id: I9fee8bbf68be6edde400d147d675ccb8979e01d8
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/406581
    Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
    Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#45453}

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0057.patch | 8++++----
Mthird_party/libwebrtc/moz-patch-stack/s0058.patch | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0059.patch | 10+++++-----
Mthird_party/libwebrtc/video/receive_statistics_proxy.cc | 23+++++++++++++----------
Mthird_party/libwebrtc/video/receive_statistics_proxy.h | 5++---
Mthird_party/libwebrtc/video/receive_statistics_proxy_unittest.cc | 1+
7 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor @@ -1,4 +1,4 @@ # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-27T20:07:16.650479+00:00. +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-27T20:09:23.701260+00:00. # base of lastest vendoring -f27f53484e +f633ab4d21 diff --git a/third_party/libwebrtc/moz-patch-stack/s0057.patch b/third_party/libwebrtc/moz-patch-stack/s0057.patch @@ -186,10 +186,10 @@ index f17b00efb1..e205032fa6 100644 void ForceSpsPpsIdrIsH264Keyframe(); diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc -index 84b00b711e..c8058ea132 100644 +index bce7093e94..152e5f8e05 100644 --- a/video/receive_statistics_proxy.cc +++ b/video/receive_statistics_proxy.cc -@@ -817,6 +817,11 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) { +@@ -820,6 +820,11 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) { })); } @@ -202,10 +202,10 @@ index 84b00b711e..c8058ea132 100644 RTC_DCHECK_RUN_ON(&main_thread_); last_codec_type_ = codec_type; diff --git a/video/receive_statistics_proxy.h b/video/receive_statistics_proxy.h -index e3cd922647..9e58f41521 100644 +index b72ed92160..82b5e54db2 100644 --- a/video/receive_statistics_proxy.h +++ b/video/receive_statistics_proxy.h -@@ -106,6 +106,7 @@ class ReceiveStatisticsProxy : public VideoStreamBufferControllerStatsObserver, +@@ -105,6 +105,7 @@ class ReceiveStatisticsProxy : public VideoStreamBufferControllerStatsObserver, void OnDecodableFrame(TimeDelta jitter_buffer_delay, TimeDelta target_delay, TimeDelta minimum_delay) override; diff --git a/third_party/libwebrtc/moz-patch-stack/s0058.patch b/third_party/libwebrtc/moz-patch-stack/s0058.patch @@ -10,10 +10,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/56fbf0469e25fa0d5 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc -index c8058ea132..568fd441d2 100644 +index 152e5f8e05..aa36333a10 100644 --- a/video/receive_statistics_proxy.cc +++ b/video/receive_statistics_proxy.cc -@@ -818,8 +818,13 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) { +@@ -821,8 +821,13 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) { } void ReceiveStatisticsProxy::OnDiscardedPackets(uint32_t packets_discarded) { diff --git a/third_party/libwebrtc/moz-patch-stack/s0059.patch b/third_party/libwebrtc/moz-patch-stack/s0059.patch @@ -116,7 +116,7 @@ index 467ceaa42d..b6e67a4309 100644 num_discarded_packets_ += num_discarded_packets; } diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc -index 568fd441d2..30eec9f090 100644 +index aa36333a10..e8e5e5ba08 100644 --- a/video/receive_statistics_proxy.cc +++ b/video/receive_statistics_proxy.cc @@ -39,6 +39,7 @@ @@ -127,7 +127,7 @@ index 568fd441d2..30eec9f090 100644 #include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" #include "video/stats_counter.h" -@@ -785,6 +786,9 @@ void ReceiveStatisticsProxy::OnCompleteFrame(bool is_keyframe, +@@ -788,6 +789,9 @@ void ReceiveStatisticsProxy::OnCompleteFrame(bool is_keyframe, VideoContentType content_type) { RTC_DCHECK_RUN_ON(&main_thread_); @@ -137,7 +137,7 @@ index 568fd441d2..30eec9f090 100644 // Content type extension is set only for keyframes and should be propagated // for all the following delta frames. Here we may receive frames out of order // and miscategorise some delta frames near the layer switch. -@@ -810,6 +814,8 @@ void ReceiveStatisticsProxy::OnCompleteFrame(bool is_keyframe, +@@ -813,6 +817,8 @@ void ReceiveStatisticsProxy::OnCompleteFrame(bool is_keyframe, void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) { // Can be called on either the decode queue or the worker thread // See FrameBuffer2 for more details. @@ -146,7 +146,7 @@ index 568fd441d2..30eec9f090 100644 worker_thread_->PostTask( SafeTask(task_safety_.flag(), [frames_dropped, this]() { RTC_DCHECK_RUN_ON(&main_thread_); -@@ -820,6 +826,9 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) { +@@ -823,6 +829,9 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) { void ReceiveStatisticsProxy::OnDiscardedPackets(uint32_t packets_discarded) { // Can be called on either the decode queue or the worker thread // See FrameBuffer2 for more details. @@ -156,7 +156,7 @@ index 568fd441d2..30eec9f090 100644 worker_thread_->PostTask( SafeTask(task_safety_.flag(), [packets_discarded, this]() { RTC_DCHECK_RUN_ON(&main_thread_); -@@ -848,6 +857,8 @@ void ReceiveStatisticsProxy::OnStreamInactive() { +@@ -851,6 +860,8 @@ void ReceiveStatisticsProxy::OnStreamInactive() { void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms) { RTC_DCHECK_RUN_ON(&main_thread_); diff --git a/third_party/libwebrtc/video/receive_statistics_proxy.cc b/third_party/libwebrtc/video/receive_statistics_proxy.cc @@ -96,8 +96,8 @@ ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t remote_ssrc, // 1000ms window, scale 1000 for ms to s. decode_fps_estimator_(1000, 1000), renders_fps_estimator_(1000, 1000), - render_fps_tracker_(100, 10u), - render_pixel_tracker_(100, 10u), + first_frame_rendered_(Timestamp::MinusInfinity()), + total_render_sqrt_pixels_(0), video_quality_observer_(new VideoQualityObserver()), interframe_delay_max_moving_(kMovingMaxWindowMs), freq_offset_counter_(clock, nullptr, kFreqOffsetProcessIntervalMs), @@ -125,7 +125,8 @@ void ReceiveStatisticsProxy::UpdateHistograms( char log_stream_buf[8 * 1024]; SimpleStringBuilder log_stream(log_stream_buf); - TimeDelta stream_duration = clock_->CurrentTime() - start_; + Timestamp now = clock_->CurrentTime(); + TimeDelta stream_duration = now - start_; if (stats_.frame_counts.key_frames > 0 || stats_.frame_counts.delta_frames > 0) { @@ -179,15 +180,16 @@ void ReceiveStatisticsProxy::UpdateHistograms( } const int kMinRequiredSamples = 200; - int samples = static_cast<int>(render_fps_tracker_.TotalSampleCount()); - if (samples >= kMinRequiredSamples) { - int rendered_fps = round(render_fps_tracker_.ComputeTotalRate()); + TimeDelta render_duration = now - first_frame_rendered_; + if (stats_.frames_rendered >= kMinRequiredSamples && + render_duration > TimeDelta::Zero()) { + int rendered_fps = (stats_.frames_rendered / render_duration).hertz(); RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.RenderFramesPerSecond", rendered_fps); log_stream << "WebRTC.Video.RenderFramesPerSecond " << rendered_fps << '\n'; RTC_HISTOGRAM_COUNTS_100000( "WebRTC.Video.RenderSqrtPixelsPerSecond", - round(render_pixel_tracker_.ComputeTotalRate())); + (total_render_sqrt_pixels_ / render_duration).hertz()); } std::optional<int> sync_offset_ms = @@ -735,12 +737,13 @@ void ReceiveStatisticsProxy::OnRenderedFrame( &content_specific_stats_[last_content_type_]; renders_fps_estimator_.Update(1, frame_meta.decode_timestamp.ms()); + if (stats_.frames_rendered == 0) { + first_frame_rendered_ = clock_->CurrentTime(); + } ++stats_.frames_rendered; stats_.width = frame_meta.width; stats_.height = frame_meta.height; - - render_fps_tracker_.AddSamples(1); - render_pixel_tracker_.AddSamples(sqrt(frame_meta.width * frame_meta.height)); + total_render_sqrt_pixels_ += sqrt(frame_meta.width * frame_meta.height); content_specific_stats->received_width.Add(frame_meta.width); content_specific_stats->received_height.Add(frame_meta.height); diff --git a/third_party/libwebrtc/video/receive_statistics_proxy.h b/third_party/libwebrtc/video/receive_statistics_proxy.h @@ -39,7 +39,6 @@ #include "rtc_base/numerics/running_statistics.h" #include "rtc_base/numerics/sample_counter.h" #include "rtc_base/rate_statistics.h" -#include "rtc_base/rate_tracker.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/thread_annotations.h" #include "video/stats_counter.h" @@ -178,8 +177,8 @@ class ReceiveStatisticsProxy : public VideoStreamBufferControllerStatsObserver, const uint32_t remote_ssrc_; RateStatistics decode_fps_estimator_ RTC_GUARDED_BY(main_thread_); RateStatistics renders_fps_estimator_ RTC_GUARDED_BY(main_thread_); - RateTracker render_fps_tracker_ RTC_GUARDED_BY(main_thread_); - RateTracker render_pixel_tracker_ RTC_GUARDED_BY(main_thread_); + Timestamp first_frame_rendered_ RTC_GUARDED_BY(main_thread_); + int64_t total_render_sqrt_pixels_ RTC_GUARDED_BY(main_thread_); SampleCounter sync_offset_counter_ RTC_GUARDED_BY(main_thread_); SampleCounter decode_time_counter_ RTC_GUARDED_BY(main_thread_); SampleCounter jitter_delay_counter_ RTC_GUARDED_BY(main_thread_); diff --git a/third_party/libwebrtc/video/receive_statistics_proxy_unittest.cc b/third_party/libwebrtc/video/receive_statistics_proxy_unittest.cc @@ -1113,6 +1113,7 @@ TEST_F(ReceiveStatisticsProxyTest, TEST_F(ReceiveStatisticsProxyTest, ReceivedFrameHistogramsAreUpdated) { for (int i = 0; i < kMinRequiredSamples; ++i) { statistics_proxy_->OnRenderedFrame(MetaData(CreateFrame(kWidth, kHeight))); + time_controller_.AdvanceTime(TimeDelta::Millis(33)); } statistics_proxy_->UpdateHistograms(std::nullopt, StreamDataCounters(),