diff --git a/BUILD.gn b/BUILD.gn index 5817d22227..1bdda46097 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -276,10 +276,16 @@ config("common_config") { defines += [ "WEBRTC_ENABLE_PROTOBUF=0" ] } - if (rtc_strict_field_trials) { - defines += [ "WEBRTC_STRICT_FIELD_TRIALS=1" ] - } else { + if (rtc_strict_field_trials == "") { defines += [ "WEBRTC_STRICT_FIELD_TRIALS=0" ] + } else if (rtc_strict_field_trials == "dcheck") { + defines += [ "WEBRTC_STRICT_FIELD_TRIALS=1" ] + } else if (rtc_strict_field_trials == "warn") { + defines += [ "WEBRTC_STRICT_FIELD_TRIALS=2" ] + } else { + assert(false, + "Unsupported value for rtc_strict_field_trials: " + + "$rtc_strict_field_trials") } if (rtc_include_internal_audio_device) { diff --git a/api/BUILD.gn b/api/BUILD.gn index c336bee27a..fbb2081e2e 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -1499,6 +1499,7 @@ rtc_source_set("field_trials_registry") { ":field_trials_view", "../experiments:registered_field_trials", "../rtc_base:checks", + "../rtc_base:logging", "../rtc_base/containers:flat_set", "../rtc_base/system:rtc_export", ] diff --git a/api/field_trials_registry.cc b/api/field_trials_registry.cc index f97e8a85a9..61d31512ce 100644 --- a/api/field_trials_registry.cc +++ b/api/field_trials_registry.cc @@ -16,14 +16,19 @@ #include "experiments/registered_field_trials.h" #include "rtc_base/checks.h" #include "rtc_base/containers/flat_set.h" +#include "rtc_base/logging.h" namespace webrtc { std::string FieldTrialsRegistry::Lookup(absl::string_view key) const { -#if WEBRTC_STRICT_FIELD_TRIALS +#if WEBRTC_STRICT_FIELD_TRIALS == 1 RTC_DCHECK(absl::c_linear_search(kRegisteredFieldTrials, key) || test_keys_.contains(key)) - << key << " is not registered."; + << key << " is not registered, see g3doc/field-trials.md."; +#elif WEBRTC_STRICT_FIELD_TRIALS == 2 + RTC_LOG_IF(LS_WARNING, !(absl::c_linear_search(kRegisteredFieldTrials, key) || + test_keys_.contains(key))) + << key << " is not registered, see g3doc/field-trials.md."; #endif return GetValue(key); } diff --git a/system_wrappers/source/field_trial.cc b/system_wrappers/source/field_trial.cc index 8f15b4eb7a..a1d21fa3ef 100644 --- a/system_wrappers/source/field_trial.cc +++ b/system_wrappers/source/field_trial.cc @@ -116,10 +116,15 @@ 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 +#if WEBRTC_STRICT_FIELD_TRIALS == 1 RTC_DCHECK(absl::c_linear_search(kRegisteredFieldTrials, name) || TestKeys().contains(name)) - << name << " is not registered."; + << 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))) + << name << " is not registered, see g3doc/field-trials.md."; #endif if (trials_init_string == NULL) diff --git a/webrtc.gni b/webrtc.gni index 8dfcc9d244..9052ba5eea 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -232,10 +232,16 @@ declare_args() { # Includes the dav1d decoder in the internal decoder factory when set to true. rtc_include_dav1d_in_internal_decoder_factory = true - # When set to true, a run-time check will make sure that all field trial keys - # have been registered in accordance with the field trial policy. The check - # will only run with builds that have RTC_DCHECKs enabled. - rtc_strict_field_trials = false + # When enabled, a run-time check will make sure that all field trial keys have + # been registered in accordance with the field trial policy, see + # g3doc/field-trials.md. The value can be set to the following: + # + # "dcheck": RTC_DCHECKs that the field trial has been registered. RTC_DCHECK + # must be enabled separately. + # + # "warn": RTC_LOGs a message with LS_WARNING severity if the field trial + # hasn't been registered. + rtc_strict_field_trials = "" } if (!build_with_mozilla) {