tor-browser

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

commit 4ae0483bd8566d826d628330cd714dae2610170f
parent bb130f40398d7dad5709f8e7bdfa39b298e17e7f
Author: Dan Baker <dbaker@mozilla.com>
Date:   Mon,  1 Dec 2025 22:40:10 -0700

Bug 2000941 - Vendor libwebrtc from e468766ed3

Upstream commit: https://webrtc.googlesource.com/src/+/e468766ed349244c237c612a8c6dca73012d0fb9
    Allow constructing objects on one thread and use on another.

    Allow AudioState and AudioDeviceBuffer to be constructed on one thread
    but used and destroyed on another.

    This is a prerequisite for allowing asynchronous termination of the
    WebRtcVoiceEngine.

    Bug: webrtc:42224720
    Change-Id: I586f2ef84cd34137eee2d57b9d954f3ed45a8898
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/410862
    Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
    Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
    Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#45697}

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/audio/BUILD.gn | 1+
Mthird_party/libwebrtc/audio/audio_state.h | 7+++++--
Mthird_party/libwebrtc/audio/audio_state_unittest.cc | 17+++++++++++++++++
Mthird_party/libwebrtc/modules/audio_device/BUILD.gn | 2++
Mthird_party/libwebrtc/modules/audio_device/audio_device_buffer.h | 6++++--
Mthird_party/libwebrtc/modules/audio_device/test_audio_device_impl_test.cc | 15+++++++++++++++
Mthird_party/libwebrtc/moz-patch-stack/s0027.patch | 14+++++++-------
Mthird_party/libwebrtc/moz-patch-stack/s0102.patch | 4++--
9 files changed, 55 insertions(+), 15 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-12-02T05:37:07.482993+00:00. +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T05:39:57.348426+00:00. # base of lastest vendoring -c9b54ede45 +e468766ed3 diff --git a/third_party/libwebrtc/audio/BUILD.gn b/third_party/libwebrtc/audio/BUILD.gn @@ -186,6 +186,7 @@ if (rtc_include_tests) { "../api:mock_frame_encryptor", "../api:mock_frame_transformer", "../api:mock_transformable_audio_frame", + "../api:ref_count", "../api:rtc_error_matchers", "../api:rtp_headers", "../api:rtp_parameters", diff --git a/third_party/libwebrtc/audio/audio_state.h b/third_party/libwebrtc/audio/audio_state.h @@ -21,6 +21,7 @@ #include "call/audio_state.h" #include "rtc_base/checks.h" #include "rtc_base/containers/flat_set.h" +#include "rtc_base/system/no_unique_address.h" #include "rtc_base/task_utils/repeating_task.h" #include "rtc_base/thread_annotations.h" @@ -66,8 +67,10 @@ class AudioState : public webrtc::AudioState { void UpdateAudioTransportWithSendingStreams(); void UpdateNullAudioPollerState() RTC_RUN_ON(&thread_checker_); - SequenceChecker thread_checker_; - SequenceChecker process_thread_checker_{SequenceChecker::kDetached}; + RTC_NO_UNIQUE_ADDRESS SequenceChecker thread_checker_{ + SequenceChecker::kDetached}; + RTC_NO_UNIQUE_ADDRESS SequenceChecker process_thread_checker_{ + SequenceChecker::kDetached}; const webrtc::AudioState::Config config_; bool recording_enabled_ = true; bool playout_enabled_ = true; diff --git a/third_party/libwebrtc/audio/audio_state_unittest.cc b/third_party/libwebrtc/audio/audio_state_unittest.cc @@ -26,6 +26,7 @@ #include "api/audio/audio_mixer.h" #include "api/location.h" #include "api/make_ref_counted.h" +#include "api/ref_count.h" #include "api/scoped_refptr.h" #include "api/task_queue/task_queue_base.h" #include "api/task_queue/task_queue_factory.h" @@ -37,6 +38,7 @@ #include "modules/audio_device/include/mock_audio_device.h" #include "modules/audio_mixer/audio_mixer_impl.h" #include "modules/audio_processing/include/mock_audio_processing.h" +#include "rtc_base/task_queue_for_test.h" #include "rtc_base/thread.h" #include "test/gmock.h" #include "test/gtest.h" @@ -49,6 +51,7 @@ using ::testing::_; using ::testing::InSequence; using ::testing::Matcher; using ::testing::NiceMock; +using ::testing::NotNull; using ::testing::StrictMock; using ::testing::Values; @@ -200,6 +203,20 @@ TEST_P(AudioStateTest, ConstructDestruct) { make_ref_counted<internal::AudioState>(helper.config())); } +TEST_P(AudioStateTest, CreateUseDeleteOnDifferentThread) { + ConfigHelper helper(GetParam()); + scoped_refptr<AudioState> audio_state = AudioState::Create(helper.config()); + ASSERT_THAT(audio_state, NotNull()); + TaskQueueForTest queue; + queue.SendTask([&] { + // Attach to the current TQ. + audio_state->SetStereoChannelSwapping(true); + // Ensure the object gets deleted on the current thread. + EXPECT_EQ(audio_state.release()->Release(), + RefCountReleaseStatus::kDroppedLastRef); + }); +} + TEST_P(AudioStateTest, RecordedAudioArrivesAtSingleStream) { ConfigHelper helper(GetParam()); diff --git a/third_party/libwebrtc/modules/audio_device/BUILD.gn b/third_party/libwebrtc/modules/audio_device/BUILD.gn @@ -77,6 +77,7 @@ if (!build_with_mozilla) { # See Bug 1820869. "../../rtc_base:timestamp_aligner", "../../rtc_base:timeutils", "../../rtc_base/synchronization:mutex", + "../../rtc_base/system:no_unique_address", "../../system_wrappers", "../../system_wrappers:metrics", ] @@ -487,6 +488,7 @@ if (rtc_include_tests && !build_with_chromium && !build_with_mozilla) { "../../rtc_base:race_checker", "../../rtc_base:rtc_event", "../../rtc_base:safe_conversions", + "../../rtc_base:task_queue_for_test", "../../rtc_base:timeutils", "../../rtc_base/synchronization:mutex", "../../system_wrappers", diff --git a/third_party/libwebrtc/modules/audio_device/audio_device_buffer.h b/third_party/libwebrtc/modules/audio_device/audio_device_buffer.h @@ -23,6 +23,7 @@ #include "api/task_queue/task_queue_base.h" #include "rtc_base/buffer.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/system/no_unique_address.h" #include "rtc_base/thread_annotations.h" #include "rtc_base/timestamp_aligner.h" @@ -153,8 +154,9 @@ class AudioDeviceBuffer { // edge cases and it is IMHO not worth the risk to use them in this class. // TODO(henrika): see if it is possible to refactor and annotate all members. - // Main thread on which this object is created. - SequenceChecker main_thread_checker_; + // Main thread for where this object is used. + RTC_NO_UNIQUE_ADDRESS SequenceChecker main_thread_checker_{ + SequenceChecker::kDetached}; Mutex lock_; diff --git a/third_party/libwebrtc/modules/audio_device/test_audio_device_impl_test.cc b/third_party/libwebrtc/modules/audio_device/test_audio_device_impl_test.cc @@ -26,6 +26,7 @@ #include "modules/audio_device/include/test_audio_device.h" #include "rtc_base/checks.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/task_queue_for_test.h" #include "rtc_base/thread_annotations.h" #include "test/create_test_environment.h" #include "test/gmock.h" @@ -187,6 +188,20 @@ TEST(TestAudioDeviceTest, EnablingRecordingProducesAudio) { ElementsAre(48000, 48000, 48000)); } +// Construct an AudioDeviceBuffer on one thread, use it and delete it on a +// different thread. +TEST(TestAudioDeviceTest, AudioDeviceBufferOnDifferentThread) { + GlobalSimulatedTimeController time_controller(kStartTime); + const Environment env = CreateTestEnvironment({.time = &time_controller}); + auto audio_buffer = std::make_unique<AudioDeviceBuffer>(env); + TaskQueueForTest queue; + queue.SendTask([&] { + TestAudioTransport audio_transport(TestAudioTransport::Mode::kRecording); + ASSERT_EQ(audio_buffer->RegisterAudioCallback(&audio_transport), 0); + audio_buffer = nullptr; + }); +} + TEST(TestAudioDeviceTest, RecordingIsAvailableWhenCapturerIsSet) { GlobalSimulatedTimeController time_controller(kStartTime); std::unique_ptr<TestAudioDeviceModule::PulsedNoiseCapturer> capturer = diff --git a/third_party/libwebrtc/moz-patch-stack/s0027.patch b/third_party/libwebrtc/moz-patch-stack/s0027.patch @@ -731,7 +731,7 @@ index 02c3ccde22..cf992635fe 100644 } diff --git a/modules/audio_device/BUILD.gn b/modules/audio_device/BUILD.gn -index 8e8a4bff5f..e57e55882c 100644 +index c8b15e4040..7ace1135c8 100644 --- a/modules/audio_device/BUILD.gn +++ b/modules/audio_device/BUILD.gn @@ -30,6 +30,7 @@ rtc_source_set("audio_device_default") { @@ -758,7 +758,7 @@ index 8e8a4bff5f..e57e55882c 100644 sources = [ "audio_device_buffer.cc", "audio_device_buffer.h", -@@ -78,6 +81,7 @@ rtc_library("audio_device_buffer") { +@@ -79,6 +82,7 @@ rtc_library("audio_device_buffer") { "../../system_wrappers:metrics", ] } @@ -766,7 +766,7 @@ index 8e8a4bff5f..e57e55882c 100644 rtc_library("audio_device_generic") { sources = [ -@@ -256,6 +260,7 @@ if (!build_with_chromium) { +@@ -257,6 +261,7 @@ if (!build_with_chromium) { # Contains default implementations of webrtc::AudioDeviceModule for Windows, # Linux, Mac, iOS and Android. rtc_library("audio_device_impl") { @@ -774,7 +774,7 @@ index 8e8a4bff5f..e57e55882c 100644 visibility = [ "*" ] deps = [ ":audio_device_buffer", -@@ -302,9 +307,9 @@ rtc_library("audio_device_impl") { +@@ -303,9 +308,9 @@ rtc_library("audio_device_impl") { sources = [ "include/fake_audio_device.h" ] if (build_with_mozilla) { @@ -787,7 +787,7 @@ index 8e8a4bff5f..e57e55882c 100644 ] } -@@ -407,6 +412,7 @@ rtc_library("audio_device_impl") { +@@ -408,6 +413,7 @@ rtc_library("audio_device_impl") { sources += [ "dummy/file_audio_device_factory.h" ] } } @@ -795,7 +795,7 @@ index 8e8a4bff5f..e57e55882c 100644 if (is_mac) { rtc_source_set("audio_device_impl_frameworks") { -@@ -424,6 +430,7 @@ if (is_mac) { +@@ -425,6 +431,7 @@ if (is_mac) { } } @@ -803,7 +803,7 @@ index 8e8a4bff5f..e57e55882c 100644 rtc_source_set("mock_audio_device") { visibility = [ "*" ] testonly = true -@@ -442,8 +449,10 @@ rtc_source_set("mock_audio_device") { +@@ -443,8 +450,10 @@ rtc_source_set("mock_audio_device") { "../../test:test_support", ] } diff --git a/third_party/libwebrtc/moz-patch-stack/s0102.patch b/third_party/libwebrtc/moz-patch-stack/s0102.patch @@ -276,7 +276,7 @@ index c6040740ce..70ed476401 100644 rtc_library("scalability_mode") { diff --git a/audio/BUILD.gn b/audio/BUILD.gn -index 3773ab8173..d2734974c9 100644 +index 3776dac967..0200d8c204 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -8,8 +8,8 @@ @@ -440,7 +440,7 @@ index 6896edbc34..ecbb7eae7e 100644 import("../webrtc.gni") diff --git a/modules/audio_device/BUILD.gn b/modules/audio_device/BUILD.gn -index e57e55882c..80af18a5fa 100644 +index 7ace1135c8..b63880a296 100644 --- a/modules/audio_device/BUILD.gn +++ b/modules/audio_device/BUILD.gn @@ -9,8 +9,8 @@