xref: /aosp_15_r20/external/webrtc/g3doc/field-trials.md (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1# Field trials
2
3<?% config.freshness.owner = 'lndmrk' %?>
4<?% config.freshness.reviewed = '2022-06-23' %?>
5
6WebRTC provides some means to alter its default behavior during run-time,
7colloquially known as *field trials*. This is foremost used for A/B testing new
8features and are related to
9[Chromium field trials](https://chromium.googlesource.com/chromium/src/+/main/testing/variations/README.md)
10to facilitate interoperability.
11
12A field trial consist of a key-value pair of strings. By convention, the field
13trial key is prefixed with `WebRTC-` and each word is capitalized without
14spaces. Sometimes the key is further subdivided into a category, for example,
15`WebRTC-MyCategory-MyExperiment`. The field trial value is an opaque string and
16it is up to the author to define what it represents. There are
17[helper functions](https://webrtc.googlesource.com/src/+/refs/heads/main/api/field_trials_view.h)
18to use a field trial as a boolean, with the string `Enabled` representing true
19and `Disabled` representing false. You can also use
20[field trial parameters](https://webrtc.googlesource.com/src/+/refs/heads/main/rtc_base/experiments/field_trial_parser.h)
21if you wish to encode more elaborate data types.
22
23The set of field trials can be instantiated from a single string with the format
24`<key-1>/<value-1>/<key-2>/<value-2>/`. Note the final `/` at the end! In
25Chromium you can launch with the `--force-fieldtrials` flag to instantiate field
26trials this way, for example:
27
28```
29--force-fieldtrials="WebRTC-Foo/Enabled/WebRTC-Bar/Disabled/"
30```
31
32## Policy
33
34The policy for field trials is:
35
36-   A field trial should only be used to test out new code or parameters for a
37    limited time period. It should not be used for configuring persistent
38    behavior.
39-   The field trial must have an end date. The end date may be pushed back if
40    necessary, but should not be pushed back indefinitely.
41-   A field trial must be associated with a bug that
42    -   reserves the field trial key,
43    -   is open,
44    -   is assigned to an owner, and
45    -   has the end date specified.
46