commit 4ce6da589eaab44ae83ed9c9bb18ee6b4194da11
parent 700aa3db51be0ccfee0e6c288fd816368313623e
Author: Michael Froman <mfroman@mozilla.com>
Date: Wed, 8 Oct 2025 18:22:04 -0500
Bug 1993083 - Vendor libwebrtc from 0d4e5e903e
Upstream commit: https://webrtc.googlesource.com/src/+/0d4e5e903e72c6e5be8e0e26b263c43a2dc1bede
Deprecate global field trials
On the way delete unused field trials helpers for testing and quering global field trials.
WebRTC is updated to rely on propaged field trials.
When field trials are not propagated it currently fallbacks to the global field trial string, but eventually that should be removed.
Bug: webrtc:42220378
Change-Id: I38d0260f15d85912a1b05faa5a3df98d674634be
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/398701
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45060}
Diffstat:
12 files changed, 45 insertions(+), 99 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 /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
-libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-08T23:20:51.490250+00:00.
+libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-08T23:21:55.042874+00:00.
# base of lastest vendoring
-7b6444606e
+0d4e5e903e
diff --git a/third_party/libwebrtc/api/environment/environment_factory.cc b/third_party/libwebrtc/api/environment/environment_factory.cc
@@ -100,7 +100,10 @@ void EnvironmentFactory::Set(
Environment EnvironmentFactory::CreateWithDefaults() && {
if (field_trials_ == nullptr) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
Set(std::make_unique<FieldTrialBasedConfig>());
+#pragma clang diagnostic pop
}
#if defined(WEBRTC_MOZILLA_BUILD)
// We want to use our clock, not GetRealTimeClockRaw, and we avoid
diff --git a/third_party/libwebrtc/api/transport/field_trial_based_config.cc b/third_party/libwebrtc/api/transport/field_trial_based_config.cc
@@ -16,6 +16,9 @@
namespace webrtc {
std::string FieldTrialBasedConfig::GetValue(absl::string_view key) const {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return field_trial::FindFullName(std::string(key));
+#pragma clang diagnostic pop
}
} // namespace webrtc
diff --git a/third_party/libwebrtc/api/transport/field_trial_based_config.h b/third_party/libwebrtc/api/transport/field_trial_based_config.h
@@ -18,7 +18,9 @@
namespace webrtc {
// Implementation using the field trial API fo the key value lookup.
-class RTC_EXPORT FieldTrialBasedConfig : public FieldTrialsRegistry {
+// TODO: bugs.webrtc.org/42220378 - Remove from public api after August 1, 2025.
+class [[deprecated]] RTC_EXPORT FieldTrialBasedConfig
+ : public FieldTrialsRegistry {
private:
std::string GetValue(absl::string_view key) const override;
};
diff --git a/third_party/libwebrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java b/third_party/libwebrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java
@@ -333,12 +333,10 @@ public class PeerConnectionClient {
Log.d(TAG, "Preferred video codec: " + getSdpVideoCodecName(peerConnectionParameters));
- final String fieldTrials = getFieldTrials(peerConnectionParameters);
executor.execute(() -> {
- Log.d(TAG, "Initialize WebRTC. Field trials: " + fieldTrials);
+ Log.d(TAG, "Initialize WebRTC.");
PeerConnectionFactory.initialize(
PeerConnectionFactory.InitializationOptions.builder(appContext)
- .setFieldTrials(fieldTrials)
.setEnableInternalTracer(true)
.createInitializationOptions());
});
@@ -446,13 +444,15 @@ public class PeerConnectionClient {
if (peerConnectionParameters.loopback) {
options.disableEncryption = true;
}
+ final String fieldTrials = getFieldTrials(peerConnectionParameters);
factory = PeerConnectionFactory.builder()
+ .setFieldTrials(fieldTrials)
.setOptions(options)
.setAudioDeviceModule(adm)
.setVideoEncoderFactory(encoderFactory)
.setVideoDecoderFactory(decoderFactory)
.createPeerConnectionFactory();
- Log.d(TAG, "Peer connection factory created.");
+ Log.d(TAG, "Peer connection factory created. Field trials: " + fieldTrials);
adm.release();
}
diff --git a/third_party/libwebrtc/examples/objc/AppRTCMobile/ios/ARDAppDelegate.m b/third_party/libwebrtc/examples/objc/AppRTCMobile/ios/ARDAppDelegate.m
@@ -10,7 +10,6 @@
#import "ARDAppDelegate.h"
-#import "sdk/objc/api/peerconnection/RTCFieldTrials.h"
#import "sdk/objc/api/peerconnection/RTCSSLAdapter.h"
#import "sdk/objc/api/peerconnection/RTCTracing.h"
#import "sdk/objc/base/RTCLogging.h"
@@ -25,8 +24,6 @@
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- NSDictionary *fieldTrials = @{};
- RTCInitFieldTrialDictionary(fieldTrials);
RTCInitializeSSL();
RTCSetupInternalTracer();
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
diff --git a/third_party/libwebrtc/moz-patch-stack/s0084.patch b/third_party/libwebrtc/moz-patch-stack/s0084.patch
@@ -23,12 +23,12 @@ index 8c481ad633..f7ac3da936 100644
"api/video:video_rtp_headers",
"test:rtp_test_utils",
diff --git a/api/environment/environment_factory.cc b/api/environment/environment_factory.cc
-index 8ee52c3d8d..97c5715872 100644
+index 0dd380a70b..4f48c1a06c 100644
--- a/api/environment/environment_factory.cc
+++ b/api/environment/environment_factory.cc
-@@ -102,12 +102,22 @@ Environment EnvironmentFactory::CreateWithDefaults() && {
- if (field_trials_ == nullptr) {
+@@ -105,12 +105,22 @@ Environment EnvironmentFactory::CreateWithDefaults() && {
Set(std::make_unique<FieldTrialBasedConfig>());
+ #pragma clang diagnostic pop
}
+#if defined(WEBRTC_MOZILLA_BUILD)
+ // We want to use our clock, not GetRealTimeClockRaw, and we avoid
diff --git a/third_party/libwebrtc/sdk/objc/api/peerconnection/RTCFieldTrials.h b/third_party/libwebrtc/sdk/objc/api/peerconnection/RTCFieldTrials.h
@@ -28,5 +28,7 @@ RTC_EXTERN NSString *const kRTCFieldTrialEnabledValue;
* values. See above for valid keys and values. Must be called before any other
* call into WebRTC. See: webrtc/system_wrappers/include/field_trial.h
*/
+// TODO: bugs.webrtc.org/42220378 - Delete after January 1, 2026.
+RTC_OBJC_DEPRECATED("Pass field trials when building PeerConnectionFactory")
RTC_EXTERN void RTCInitFieldTrialDictionary(
NSDictionary<NSString *, NSString *> *fieldTrials);
diff --git a/third_party/libwebrtc/sdk/objc/api/peerconnection/RTCFieldTrials.mm b/third_party/libwebrtc/sdk/objc/api/peerconnection/RTCFieldTrials.mm
@@ -58,5 +58,8 @@ void RTCInitFieldTrialDictionary(
RTCLogError(@"Failed to convert field trial string.");
return;
}
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
webrtc::field_trial::InitFieldTrialsFromString(gFieldTrialInitString);
+#pragma clang diagnostic pop
}
diff --git a/third_party/libwebrtc/system_wrappers/include/field_trial.h b/third_party/libwebrtc/system_wrappers/include/field_trial.h
@@ -14,48 +14,13 @@
#include <string>
#include "absl/strings/string_view.h"
-#include "rtc_base/containers/flat_set.h"
// Field trials allow webrtc clients (such as Chrome) to turn on feature code
// in binaries out in the field and gather information with that.
//
-// By default WebRTC provides an implementation of field trials that can be
-// found in system_wrappers/source/field_trial.cc. If clients want to provide
-// a custom version, they will have to:
-//
-// 1. Compile WebRTC defining the preprocessor macro
-// WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT (if GN is used this can be achieved
-// by setting the GN arg rtc_exclude_field_trial_default to true).
-// 2. Provide an implementation of:
-// std::string webrtc::field_trial::FindFullName(absl::string_view trial).
-//
-// They are designed to wire up directly to chrome field trials and to speed up
-// developers by reducing the need to wire APIs to control whether a feature is
-// on/off. E.g. to experiment with a new method that could lead to a different
-// trade-off between CPU/bandwidth:
-//
-// 1 - Develop the feature with default behaviour off:
-//
-// if (FieldTrial::FindFullName("WebRTCExperimentMethod2") == "Enabled")
-// method2();
-// else
-// method1();
-//
-// 2 - Once the changes are rolled to chrome, the new code path can be
-// controlled as normal chrome field trials.
-//
-// 3 - Evaluate the new feature and clean the code paths.
-//
-// Notes:
-// - NOT every feature is a candidate to be controlled by this mechanism as
-// it may require negotiation between involved parties (e.g. SDP).
-//
-// TODO(andresp): since chrome --force-fieldtrials does not marks the trial
-// as active it does not get propagated to the renderer process. For now one
-// needs to push a config with start_active:true or run a local finch
-// server.
-//
-// TODO(andresp): find out how to get bots to run tests with trials enabled.
+// Field trials interface provided in this file is deprecated.
+// Please use `api/field_trials.h` to create field trials.
+// Please use `api/field_trials_view.h` to query field trials.
namespace webrtc {
namespace field_trial {
@@ -64,30 +29,26 @@ namespace field_trial {
// if the trial does not exists.
//
// Note: To keep things tidy append all the trial names with WebRTC.
+// TODO: bugs.webrtc.org/42220378 - Remove from api after August 1, 2025.
+[[deprecated]]
std::string FindFullName(absl::string_view name);
-// Convenience method, returns true iff FindFullName(name) return a string that
-// starts with "Enabled".
-// TODO(tommi): Make sure all implementations support this.
-inline bool IsEnabled(absl::string_view name) {
- return FindFullName(name).find("Enabled") == 0;
-}
-
-// Convenience method, returns true iff FindFullName(name) return a string that
-// starts with "Disabled".
-inline bool IsDisabled(absl::string_view name) {
- return FindFullName(name).find("Disabled") == 0;
-}
-
// Optionally initialize field trial from a string.
// This method can be called at most once before any other call into webrtc.
// E.g. before the peer connection factory is constructed.
// Note: trials_string must never be destroyed.
+// TODO: bugs.webrtc.org/42220378 - Delete after January 1, 2026.
+[[deprecated(
+ "Create FieldTrials and pass is where FieldTrialsView is expected")]]
void InitFieldTrialsFromString(const char* trials_string);
+// TODO: bugs.webrtc.org/42220378 - Remove from api after September 1, 2025.
+[[deprecated("Propagate and query FieldTrialsView interface")]]
const char* GetFieldTrialString();
// Validates the given field trial string.
+// TODO: bugs.webrtc.org/42220378 - Delete after January 1, 2026.
+[[deprecated("Use FieldTrials::Create to validate field trial string")]]
bool FieldTrialsStringIsValid(absl::string_view trials_string);
// Merges two field trial strings.
@@ -95,21 +56,11 @@ bool FieldTrialsStringIsValid(absl::string_view trials_string);
// If a key (trial) exists twice with conflicting values (groups), the value
// in 'second' takes precedence.
// Shall only be called with valid FieldTrial strings.
+// TODO: bugs.webrtc.org/42220378 - Delete after January 1, 2026.
+[[deprecated("Use FieldTrials::Merge")]]
std::string MergeFieldTrialsStrings(absl::string_view first,
absl::string_view second);
-// This helper allows to temporary "register" a field trial within the current
-// scope. This is only useful for tests that use the global field trial string,
-// otherwise you can use `webrtc::FieldTrialsRegistry`.
-//
-// If you want to isolate changes to the global field trial string itself within
-// the current scope you should use `webrtc::test::ScopedFieldTrials`.
-class FieldTrialsAllowedInScopeForTesting {
- public:
- explicit FieldTrialsAllowedInScopeForTesting(flat_set<std::string> keys);
- ~FieldTrialsAllowedInScopeForTesting();
-};
-
} // namespace field_trial
} // namespace webrtc
diff --git a/third_party/libwebrtc/system_wrappers/source/field_trial.cc b/third_party/libwebrtc/system_wrappers/source/field_trial.cc
@@ -14,12 +14,12 @@
#include <map>
#include <string>
#include <utility>
+#include <vector>
#include "absl/algorithm/container.h"
#include "absl/strings/string_view.h"
#include "experiments/registered_field_trials.h"
#include "rtc_base/checks.h"
-#include "rtc_base/containers/flat_set.h"
#include "rtc_base/logging.h"
#include "rtc_base/string_encode.h"
@@ -34,11 +34,6 @@ namespace {
constexpr char kPersistentStringSeparator = '/';
-flat_set<std::string>& TestKeys() {
- static auto* test_keys = new flat_set<std::string>();
- return *test_keys;
-}
-
// Validates the given field trial string.
// E.g.:
// "WebRTC-experimentFoo/Enabled/WebRTC-experimentBar/Enabled100kbps/"
@@ -117,13 +112,10 @@ std::string MergeFieldTrialsStrings(absl::string_view first,
#ifndef WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT
std::string FindFullName(absl::string_view name) {
#if WEBRTC_STRICT_FIELD_TRIALS == 1
- RTC_DCHECK(absl::c_linear_search(kRegisteredFieldTrials, name) ||
- TestKeys().contains(name))
+ RTC_DCHECK(absl::c_linear_search(kRegisteredFieldTrials, name))
<< name << " is not registered, see g3doc/field-trials.md.";
#elif WEBRTC_STRICT_FIELD_TRIALS == 2
- RTC_LOG_IF(LS_WARNING,
- !(absl::c_linear_search(kRegisteredFieldTrials, name) ||
- TestKeys().contains(name)))
+ RTC_LOG_IF(LS_WARNING, !absl::c_linear_search(kRegisteredFieldTrials, name))
<< name << " is not registered, see g3doc/field-trials.md.";
#endif
@@ -173,14 +165,5 @@ const char* GetFieldTrialString() {
return trials_init_string;
}
-FieldTrialsAllowedInScopeForTesting::FieldTrialsAllowedInScopeForTesting(
- flat_set<std::string> keys) {
- TestKeys() = std::move(keys);
-}
-
-FieldTrialsAllowedInScopeForTesting::~FieldTrialsAllowedInScopeForTesting() {
- TestKeys().clear();
-}
-
} // namespace field_trial
} // namespace webrtc
diff --git a/third_party/libwebrtc/system_wrappers/source/field_trial_unittest.cc b/third_party/libwebrtc/system_wrappers/source/field_trial_unittest.cc
@@ -15,8 +15,10 @@
namespace webrtc {
namespace field_trial {
-#if GTEST_HAS_DEATH_TEST && RTC_DCHECK_IS_ON && !defined(WEBRTC_ANDROID) && \
- !defined(WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT)
+#if GTEST_HAS_DEATH_TEST && RTC_DCHECK_IS_ON && !defined(WEBRTC_ANDROID)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
TEST(FieldTrialValidationTest, AcceptsValidInputs) {
InitFieldTrialsFromString("");
InitFieldTrialsFromString("Audio/Enabled/");
@@ -100,8 +102,8 @@ TEST(FieldTrialMergingTest, HandlesEmptyInput) {
EXPECT_EQ(MergeFieldTrialsStrings("Audio/Enabled/", ""), "Audio/Enabled/");
EXPECT_EQ(MergeFieldTrialsStrings("", ""), "");
}
+#pragma clang diagnostic pop
#endif // GTEST_HAS_DEATH_TEST && RTC_DCHECK_IS_ON && !defined(WEBRTC_ANDROID)
- // && !defined(WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT)
} // namespace field_trial
} // namespace webrtc