tor-browser

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

commit d186266f31e0790389b761dda093c4234f1d4df2
parent 5720777005817d7ac8075193c21ec785371dc99e
Author: Dan Baker <dbaker@mozilla.com>
Date:   Thu, 23 Oct 2025 15:22:02 -0600

Bug 1995393 - Vendor libwebrtc from d2e6050e9b

Upstream commit: https://webrtc.googlesource.com/src/+/d2e6050e9b51c4b18cdcbb6d8d72c26344dbd97d
    Use propagated clock in RtcEventLog implementation

    Bug: webrtc:42223992
    Change-Id: I0d6a171f36a66b0292c3ef8ff15f806ed2114be5
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/404480
    Reviewed-by: Björn Terelius <terelius@webrtc.org>
    Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#45340}

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/logging/BUILD.gn | 1+
Mthird_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.cc | 21+++++++++++----------
Mthird_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.h | 5+++--
Mthird_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl_unittest.cc | 7++++---
Mthird_party/libwebrtc/logging/rtc_event_log/rtc_event_log_unittest_helper.cc | 16+++++++++++++---
Mthird_party/libwebrtc/moz-patch-stack/s0102.patch | 2+-
7 files changed, 35 insertions(+), 21 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-23T21:19:08.686935+00:00. +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-23T21:21:51.586958+00:00. # base of lastest vendoring -ad873017aa +d2e6050e9b diff --git a/third_party/libwebrtc/logging/BUILD.gn b/third_party/libwebrtc/logging/BUILD.gn @@ -628,6 +628,7 @@ if (rtc_enable_protobuf) { "../rtc_base:safe_conversions", "../rtc_base:timeutils", "../system_wrappers", + "../test:create_test_environment", "../test:create_test_field_trials", "../test:fileutils", "../test:test_support", diff --git a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.cc b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.cc @@ -54,17 +54,18 @@ std::unique_ptr<RtcEventLogEncoder> CreateEncoder(const Environment& env) { } // namespace RtcEventLogImpl::RtcEventLogImpl(const Environment& env) - : RtcEventLogImpl(CreateEncoder(env), &env.task_queue_factory()) {} + : RtcEventLogImpl(env, CreateEncoder(env)) {} -RtcEventLogImpl::RtcEventLogImpl(std::unique_ptr<RtcEventLogEncoder> encoder, - TaskQueueFactory* task_queue_factory, +RtcEventLogImpl::RtcEventLogImpl(const Environment& env, + std::unique_ptr<RtcEventLogEncoder> encoder, size_t max_events_in_history, size_t max_config_events_in_history) - : max_events_in_history_(max_events_in_history), + : env_(env), + max_events_in_history_(max_events_in_history), max_config_events_in_history_(max_config_events_in_history), event_encoder_(std::move(encoder)), - last_output_ms_(TimeMillis()), - task_queue_(task_queue_factory->CreateTaskQueue( + last_output_ms_(env_.clock().TimeInMilliseconds()), + task_queue_(env_.task_queue_factory().CreateTaskQueue( "rtc_event_log", TaskQueueFactory::Priority::NORMAL)) {} @@ -99,7 +100,7 @@ bool RtcEventLogImpl::StartLogging(std::unique_ptr<RtcEventLogOutput> output, return false; } - const int64_t timestamp_us = TimeMillis() * 1000; + const int64_t timestamp_us = env_.clock().TimeInMicroseconds(); const int64_t utc_time_us = TimeUTCMillis() * 1000; RTC_LOG(LS_INFO) << "Starting WebRTC event log. (Timestamp, UTC) = (" << timestamp_us << ", " << utc_time_us << ")."; @@ -234,7 +235,7 @@ void RtcEventLogImpl::ScheduleOutput() { LogEventsToOutput(std::move(histories)); } }; - const int64_t now_ms = TimeMillis(); + const int64_t now_ms = env_.clock().TimeInMilliseconds(); const int64_t time_since_output_ms = now_ms - last_output_ms_; const int32_t delay = SafeClamp(output_period_ms_ - time_since_output_ms, 0, output_period_ms_); @@ -257,7 +258,7 @@ void RtcEventLogImpl::LogToMemory(std::unique_ptr<RtcEvent> event) { } void RtcEventLogImpl::LogEventsToOutput(EventHistories histories) { - last_output_ms_ = TimeMillis(); + last_output_ms_ = env_.clock().TimeInMilliseconds(); // Serialize the stream configurations. std::string encoded_configs = event_encoder_->EncodeBatch( @@ -318,7 +319,7 @@ void RtcEventLogImpl::StopOutput() { void RtcEventLogImpl::StopLoggingInternal() { if (event_output_) { RTC_DCHECK(event_output_->IsActive()); - const int64_t timestamp_us = TimeMillis() * 1000; + const int64_t timestamp_us = env_.clock().TimeInMicroseconds(); event_output_->Write(event_encoder_->EncodeLogEnd(timestamp_us)); } StopOutput(); diff --git a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.h b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl.h @@ -24,7 +24,6 @@ #include "api/rtc_event_log_output.h" #include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" -#include "api/task_queue/task_queue_factory.h" #include "logging/rtc_event_log/encoder/rtc_event_log_encoder.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/no_unique_address.h" @@ -43,8 +42,8 @@ class RtcEventLogImpl final : public RtcEventLog { explicit RtcEventLogImpl(const Environment& env); RtcEventLogImpl( + const Environment& env, std::unique_ptr<RtcEventLogEncoder> encoder, - TaskQueueFactory* task_queue_factory, size_t max_events_in_history = kMaxEventsInHistory, size_t max_config_events_in_history = kMaxEventsInConfigHistory); RtcEventLogImpl(const RtcEventLogImpl&) = delete; @@ -89,6 +88,8 @@ class RtcEventLogImpl final : public RtcEventLog { bool ShouldOutputImmediately() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); void ScheduleOutput() RTC_RUN_ON(task_queue_); + const Environment env_; + // Max size of event history. const size_t max_events_in_history_; diff --git a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl_unittest.cc b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_impl_unittest.cc @@ -24,6 +24,7 @@ #include "api/units/timestamp.h" #include "logging/rtc_event_log/encoder/rtc_event_log_encoder.h" #include "rtc_base/checks.h" +#include "test/create_test_environment.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/time_controller/simulated_time_controller.h" @@ -115,9 +116,9 @@ class RtcEventLogImplTest : public ::testing::Test { std::unique_ptr<FakeOutput> output_ = std::make_unique<FakeOutput>(written_data_); FakeOutput* output_ptr_ = output_.get(); - RtcEventLogImpl event_log_{std::move(encoder_), - time_controller_.GetTaskQueueFactory(), - kMaxEventsInHistory, kMaxEventsInConfigHistory}; + RtcEventLogImpl event_log_{CreateTestEnvironment({.time = &time_controller_}), + std::move(encoder_), kMaxEventsInHistory, + kMaxEventsInConfigHistory}; }; TEST_F(RtcEventLogImplTest, WritesHeaderAndEventsAndTrailer) { diff --git a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_unittest_helper.cc b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_unittest_helper.cc @@ -126,6 +126,10 @@ constexpr ExtensionPair kExtensions[kMaxNumExtensions] = { {RTPExtensionType::kRtpExtensionDependencyDescriptor, RtpExtension::kDependencyDescriptorUri}}; +MATCHER_P2(Near, value, margin, "") { + return value - margin < arg && arg < value + margin; +} + template <typename T> void ShuffleInPlace(Random* prng, ArrayView<T> array) { RTC_DCHECK_LE(array.size(), std::numeric_limits<uint32_t>::max()); @@ -1402,16 +1406,22 @@ void EventVerifier::VerifyLoggedStartEvent( int64_t start_time_us, int64_t utc_start_time_us, const LoggedStartEvent& logged_event) const { - EXPECT_EQ(start_time_us / 1000, logged_event.log_time_ms()); + // Use approximate comparison to support various roundings to milliseconds. + EXPECT_THAT(logged_event.log_time(), + Near(Timestamp::Micros(start_time_us), TimeDelta::Millis(1))); if (encoding_type_ == RtcEventLog::EncodingType::NewFormat) { - EXPECT_EQ(utc_start_time_us / 1000, logged_event.utc_start_time.ms()); + EXPECT_THAT( + logged_event.utc_start_time, + Near(Timestamp::Micros(utc_start_time_us), TimeDelta::Millis(1))); } } void EventVerifier::VerifyLoggedStopEvent( int64_t stop_time_us, const LoggedStopEvent& logged_event) const { - EXPECT_EQ(stop_time_us / 1000, logged_event.log_time_ms()); + // Use approximate comparison to support various roundings to milliseconds. + EXPECT_THAT(logged_event.log_time(), + Near(Timestamp::Micros(stop_time_us), TimeDelta::Millis(1))); } void VerifyLoggedStreamConfig(const rtclog::StreamConfig& original_config, diff --git a/third_party/libwebrtc/moz-patch-stack/s0102.patch b/third_party/libwebrtc/moz-patch-stack/s0102.patch @@ -412,7 +412,7 @@ index af82ba39db..2306fe1886 100644 deps = [ ":generated_jni", diff --git a/logging/BUILD.gn b/logging/BUILD.gn -index 187019693e..e1edf6befb 100644 +index 401dca948a..cadd4bab1b 100644 --- a/logging/BUILD.gn +++ b/logging/BUILD.gn @@ -11,8 +11,8 @@ if (rtc_enable_protobuf) {