mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Add option to log a warning for unregistered field trials
Until now you only had the option to RTC_DCHECK for unregistered field trials. This makes it possible to log a warning instead. Bug: webrtc:14154 Change-Id: I8628054e3c9b5d690f241a93e61299126b732ed0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295300 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Emil Lundmark <lndmrk@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39417}
This commit is contained in:
parent
95250db10d
commit
9109e856d5
5 changed files with 34 additions and 11 deletions
12
BUILD.gn
12
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) {
|
||||
|
|
|
@ -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",
|
||||
]
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
14
webrtc.gni
14
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) {
|
||||
|
|
Loading…
Reference in a new issue