tor-browser

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

commit b8bae628e7fe0059660b345a22ada65ce91c3af6
parent 676f036feab5e66c8ea4bb0ce1cf8d9d2503dcfa
Author: Michael Froman <mfroman@mozilla.com>
Date:   Thu,  9 Oct 2025 22:07:55 -0500

Bug 1993083 - Vendor libwebrtc from 33b8c034b1

(skip-generation)

Upstream commit: https://webrtc.googlesource.com/src/+/33b8c034b1911e390d16225528e5a2aabdbae625
    Reland "Allow StdoutMetricsExporter to merge stream and peers info in test_name."

    This is a reland of commit 772386c50321aabfcaeea75857515d6f939c6ac1

    Original change's description:
    > Allow StdoutMetricsExporter to merge stream and peers info in test_name.
    >
    > Currently, metrics printed by StdoutMetricsExporter have lost info
    > about stream, sender/receiver and peers. They look like:
    >
    > RESULT psnr_dB: foreman_cif_net_delay_0_0_plr_0_VP9= {38.697086,1.7471016} unitless_biggerIsBetter
    >
    > Which makes it impossible to know the stream to which this PSNR
    > measurement was referring to.
    >
    > This CL tries to restore the behaviour before [1], which changed test
    > names with:
    >
    > std::string DefaultVideoQualityAnalyzer::GetTestCaseName(
    >     const std::string& stream_label) const {
    >   if (!absl::GetFlag(FLAGS_isolated_script_test_perf_output).empty()) {
    >     return test_label_ + "/" + stream_label;
    >   }
    >   return test_label_;
    > }
    >
    > [1] - https://webrtc-review.googlesource.com/c/src/+/383720
    >
    > Bug: None
    > Change-Id: Iad3cf5cb723e37c2a32fc510a2d484b796024ace
    > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/399280
    > Reviewed-by: Jeremy Leconte <jleconte@google.com>
    > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
    > Cr-Commit-Position: refs/heads/main@{#45185}

    Bug: b/433477101
    Change-Id: I8c6bf97835c98ae683a17554e0eecdf44c62c3df
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/401560
    Reviewed-by: Jeremy Leconte <jleconte@google.com>
    Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#45200}

Diffstat:
Mthird_party/libwebrtc/BUILD.gn | 1-
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/api/test/metrics/BUILD.gn | 39++++++++++++++++++++++++++-------------
Mthird_party/libwebrtc/api/test/metrics/stdout_metrics_exporter.cc | 22+++++++++++++++++++++-
Mthird_party/libwebrtc/api/test/metrics/stdout_metrics_exporter_test.cc | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------
Mthird_party/libwebrtc/moz-patch-stack/s0027.patch | 8++++----
Mthird_party/libwebrtc/moz-patch-stack/s0034.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0045.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0055.patch | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0084.patch | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0093.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0099.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0103.patch | 10+++++-----
Mthird_party/libwebrtc/moz-patch-stack/s0106.patch | 6+++---
Mthird_party/libwebrtc/moz-patch-stack/s0108.patch | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0112.patch | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0129.patch | 2+-
Mthird_party/libwebrtc/rtc_tools/BUILD.gn | 3++-
Mthird_party/libwebrtc/rtc_tools/frame_analyzer/frame_analyzer.cc | 100++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mthird_party/libwebrtc/test/BUILD.gn | 4++--
20 files changed, 240 insertions(+), 70 deletions(-)

diff --git a/third_party/libwebrtc/BUILD.gn b/third_party/libwebrtc/BUILD.gn @@ -564,7 +564,6 @@ if (!build_with_chromium) { "api/rtc_event_log:rtc_event_log_factory", "api/task_queue", "api/task_queue:default_task_queue_factory", - "api/test/metrics", "api/video_codecs:video_decoder_factory_template", "api/video_codecs:video_decoder_factory_template_dav1d_adapter", "api/video_codecs:video_decoder_factory_template_libvpx_vp8_adapter", 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-10T03:06:39.839239+00:00. +libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-10T03:07:45.373550+00:00. # base of lastest vendoring -3bb0bd9f36 +33b8c034b1 diff --git a/third_party/libwebrtc/api/test/metrics/BUILD.gn b/third_party/libwebrtc/api/test/metrics/BUILD.gn @@ -12,14 +12,17 @@ if (rtc_enable_protobuf) { } group("metrics") { + testonly = true deps = [ ":global_metrics_logger_and_exporter", ":metric", ":metrics_accumulator", ":metrics_exporter", ":metrics_logger", - ":stdout_metrics_exporter", ] + if (!build_with_chromium) { + deps += [ ":stdout_metrics_exporter" ] + } } if (rtc_include_tests) { @@ -98,18 +101,26 @@ rtc_library("metrics_exporter") { ] } -rtc_library("stdout_metrics_exporter") { - visibility = [ "*" ] - sources = [ - "stdout_metrics_exporter.cc", - "stdout_metrics_exporter.h", - ] - deps = [ - ":metric", - ":metrics_exporter", - "../..:array_view", - "../../../rtc_base:stringutils", - ] +if (!build_with_chromium) { + # Hidden from the Chromium build because it depends on absl flags which + # cannot be compiled in Chromium. + rtc_library("stdout_metrics_exporter") { + visibility = [ "*" ] + testonly = true + sources = [ + "stdout_metrics_exporter.cc", + "stdout_metrics_exporter.h", + ] + deps = [ + ":metric", + ":metrics_exporter", + "../..:array_view", + "../../../rtc_base:stringutils", + "../../../test:test_flags", + "//third_party/abseil-cpp/absl/flags:flag", + "//third_party/abseil-cpp/absl/strings", + ] + } } rtc_library("chrome_perf_dashboard_metrics_exporter") { @@ -222,8 +233,10 @@ if (rtc_include_tests) { deps = [ ":metric", ":stdout_metrics_exporter", + "../../../test:test_flags", "../../../test:test_support", "../../units:timestamp", + "//third_party/abseil-cpp/absl/flags:flag", ] } diff --git a/third_party/libwebrtc/api/test/metrics/stdout_metrics_exporter.cc b/third_party/libwebrtc/api/test/metrics/stdout_metrics_exporter.cc @@ -15,9 +15,12 @@ #include <optional> #include <string> +#include "absl/flags/flag.h" +#include "absl/strings/str_cat.h" #include "api/array_view.h" #include "api/test/metrics/metric.h" #include "rtc_base/strings/string_builder.h" +#include "test/test_flags.h" namespace webrtc { namespace test { @@ -66,6 +69,22 @@ void AppendWithPrecision(double value, } } +std::string TestCaseAndMetadata(const Metric& metric) { + if (absl::GetFlag(FLAGS_isolated_script_test_perf_output).empty()) { + if (metric.metric_metadata.contains("video_stream")) { + return absl::StrCat(metric.test_case, "/", + metric.metric_metadata.at("video_stream"), "_", + metric.metric_metadata.at("sender"), "_", + metric.metric_metadata.at("receiver")); + } + if (metric.metric_metadata.contains("peer")) { + return absl::StrCat(metric.test_case, "/", + metric.metric_metadata.at("peer")); + } + } + return metric.test_case; +} + } // namespace StdoutMetricsExporter::StdoutMetricsExporter() : output_(stdout) {} @@ -79,7 +98,8 @@ bool StdoutMetricsExporter::Export(ArrayView<const Metric> metrics) { void StdoutMetricsExporter::PrintMetric(const Metric& metric) { StringBuilder value_stream; - value_stream << metric.test_case << " / " << metric.name << "= {mean="; + value_stream << TestCaseAndMetadata(metric) << " / " << metric.name + << "= {mean="; if (metric.stats.mean.has_value()) { AppendWithPrecision(*metric.stats.mean, 8, value_stream); } else { diff --git a/third_party/libwebrtc/api/test/metrics/stdout_metrics_exporter_test.cc b/third_party/libwebrtc/api/test/metrics/stdout_metrics_exporter_test.cc @@ -13,9 +13,11 @@ #include <string> #include <vector> +#include "absl/flags/flag.h" #include "api/test/metrics/metric.h" #include "api/units/timestamp.h" #include "test/gtest.h" +#include "test/test_flags.h" namespace webrtc { namespace test { @@ -42,27 +44,51 @@ Metric PsnrForTestFoo(double mean, double stddev) { .stats = Metric::Stats{.mean = mean, .stddev = stddev}}; } -TEST(StdoutMetricsExporterTest, ExportMetricFormatCorrect) { - Metric metric1{ - .name = "test_metric1", - .unit = Unit::kMilliseconds, - .improvement_direction = ImprovementDirection::kBiggerIsBetter, - .test_case = "test_case_name1", - .metric_metadata = DefaultMetadata(), - .time_series = - Metric::TimeSeries{.samples = std::vector{Sample(10), Sample(20)}}, - .stats = - Metric::Stats{.mean = 15.0, .stddev = 5.0, .min = 10.0, .max = 20.0}}; - Metric metric2{ - .name = "test_metric2", - .unit = Unit::kKilobitsPerSecond, - .improvement_direction = ImprovementDirection::kSmallerIsBetter, - .test_case = "test_case_name2", - .metric_metadata = DefaultMetadata(), - .time_series = - Metric::TimeSeries{.samples = std::vector{Sample(20), Sample(40)}}, - .stats = Metric::Stats{ - .mean = 30.0, .stddev = 10.0, .min = 20.0, .max = 40.0}}; +class StdoutMetricsExporterTest : public ::testing::Test { + public: + StdoutMetricsExporterTest() { + original_isolated_script_test_perf_output_ = + absl::GetFlag(FLAGS_isolated_script_test_perf_output); + + metric1_ = { + .name = "test_metric1", + .unit = Unit::kMilliseconds, + .improvement_direction = ImprovementDirection::kBiggerIsBetter, + .test_case = "test_case_name1", + .metric_metadata = + std::map<std::string, std::string>{{"video_stream", "alice_stream"}, + {"sender", "alice"}, + {"receiver", "bob"}}, + .time_series = + Metric::TimeSeries{.samples = std::vector{Sample(10), Sample(20)}}, + .stats = Metric::Stats{ + .mean = 15.0, .stddev = 5.0, .min = 10.0, .max = 20.0}}; + metric2_ = { + .name = "test_metric2", + .unit = Unit::kKilobitsPerSecond, + .improvement_direction = ImprovementDirection::kSmallerIsBetter, + .test_case = "test_case_name2", + .metric_metadata = + std::map<std::string, std::string>{{"peer", "alice"}}, + .time_series = + Metric::TimeSeries{.samples = std::vector{Sample(20), Sample(40)}}, + .stats = Metric::Stats{ + .mean = 30.0, .stddev = 10.0, .min = 20.0, .max = 40.0}}; + } + ~StdoutMetricsExporterTest() { + absl::SetFlag(&FLAGS_isolated_script_test_perf_output, + original_isolated_script_test_perf_output_); + } + + protected: + std::string original_isolated_script_test_perf_output_; + Metric metric1_; + Metric metric2_; +}; + +TEST_F(StdoutMetricsExporterTest, + ExportMetricFormatCorrectWhenIsolatedScriptTestPerfOutputIsSet) { + absl::SetFlag(&FLAGS_isolated_script_test_perf_output, "/tmp/foo"); testing::internal::CaptureStdout(); StdoutMetricsExporter exporter; @@ -73,7 +99,24 @@ TEST(StdoutMetricsExporterTest, ExportMetricFormatCorrect) { "RESULT: test_case_name2 / test_metric2= " "{mean=30, stddev=10} KilobitsPerSecond (SmallerIsBetter)\n"; - EXPECT_TRUE(exporter.Export(std::vector<Metric>{metric1, metric2})); + EXPECT_TRUE(exporter.Export(std::vector<Metric>{metric1_, metric2_})); + EXPECT_EQ(expected, testing::internal::GetCapturedStdout()); +} + +TEST_F(StdoutMetricsExporterTest, + ExportMetricFormatCorrectWhenIsolatedScriptTestPerfOutputIsNotSet) { + absl::SetFlag(&FLAGS_isolated_script_test_perf_output, ""); + + testing::internal::CaptureStdout(); + StdoutMetricsExporter exporter; + + std::string expected = + "RESULT: test_case_name1/alice_stream_alice_bob / test_metric1= " + "{mean=15, stddev=5} Milliseconds (BiggerIsBetter)\n" + "RESULT: test_case_name2/alice / test_metric2= " + "{mean=30, stddev=10} KilobitsPerSecond (SmallerIsBetter)\n"; + + EXPECT_TRUE(exporter.Export(std::vector<Metric>{metric1_, metric2_})); EXPECT_EQ(expected, testing::internal::GetCapturedStdout()); } diff --git a/third_party/libwebrtc/moz-patch-stack/s0027.patch b/third_party/libwebrtc/moz-patch-stack/s0027.patch @@ -116,7 +116,7 @@ index 1b112b34c0..18cf5d67f7 100644 # TODO(https://bugs.webrtc.org/14437): Remove this section if general # Chromium fix resolves the problem. diff --git a/BUILD.gn b/BUILD.gn -index bc948d4f2b..f5944b313c 100644 +index 3357c2dcdf..db3f2454bc 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -33,7 +33,7 @@ if (is_android) { @@ -151,7 +151,7 @@ index bc948d4f2b..f5944b313c 100644 if (!rtc_build_ssl) { config("external_ssl_library") { -@@ -564,6 +570,34 @@ if (!build_with_chromium) { +@@ -563,6 +569,34 @@ if (!build_with_chromium) { "sdk", "video", ] @@ -186,7 +186,7 @@ index bc948d4f2b..f5944b313c 100644 if (rtc_include_builtin_audio_codecs) { deps += [ -@@ -576,6 +610,16 @@ if (!build_with_chromium) { +@@ -575,6 +609,16 @@ if (!build_with_chromium) { deps += [ "api/video:video_frame", "api/video:video_rtp_headers", @@ -1200,7 +1200,7 @@ index c1181618e9..4a772795ed 100644 deps += [ "..:logging", diff --git a/test/BUILD.gn b/test/BUILD.gn -index f5dd45f86b..c206c33f49 100644 +index b07102a7d5..4b7bd27de2 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -258,6 +258,7 @@ rtc_library("audio_test_common") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0034.patch b/third_party/libwebrtc/moz-patch-stack/s0034.patch @@ -20,7 +20,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/58f47eacaf10d12e2 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/BUILD.gn b/BUILD.gn -index f5944b313c..e65e8f9860 100644 +index db3f2454bc..cd737fefbd 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -440,12 +440,12 @@ config("common_config") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0045.patch b/third_party/libwebrtc/moz-patch-stack/s0045.patch @@ -18,7 +18,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0300b32b7de70fb89 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/BUILD.gn b/BUILD.gn -index e65e8f9860..dc859f91c3 100644 +index cd737fefbd..614d251e40 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -224,6 +224,9 @@ config("common_inherited_config") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0055.patch b/third_party/libwebrtc/moz-patch-stack/s0055.patch @@ -11,10 +11,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b0658888969395dca 2 files changed, 10 insertions(+) diff --git a/BUILD.gn b/BUILD.gn -index dc859f91c3..dfff7bf799 100644 +index 614d251e40..bf346ec180 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -626,6 +626,10 @@ if (!build_with_chromium) { +@@ -625,6 +625,10 @@ if (!build_with_chromium) { ] } diff --git a/third_party/libwebrtc/moz-patch-stack/s0084.patch b/third_party/libwebrtc/moz-patch-stack/s0084.patch @@ -11,10 +11,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2185cab977988fd4a 3 files changed, 16 insertions(+) diff --git a/BUILD.gn b/BUILD.gn -index dfff7bf799..7d55451f4e 100644 +index bf346ec180..79bd26b2cf 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -611,6 +611,7 @@ if (!build_with_chromium) { +@@ -610,6 +610,7 @@ if (!build_with_chromium) { if (build_with_mozilla) { deps += [ diff --git a/third_party/libwebrtc/moz-patch-stack/s0093.patch b/third_party/libwebrtc/moz-patch-stack/s0093.patch @@ -10,7 +10,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b050c455caa1d24a0 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/BUILD.gn b/BUILD.gn -index 7d55451f4e..4501b6d714 100644 +index 79bd26b2cf..9ebcd0de52 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -280,6 +280,7 @@ config("rtc_prod_config") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0099.patch b/third_party/libwebrtc/moz-patch-stack/s0099.patch @@ -86,7 +86,7 @@ index 2c278341c7..27410af8a8 100644 if (!build_with_mozilla) { diff --git a/test/BUILD.gn b/test/BUILD.gn -index c206c33f49..6b73a8e345 100644 +index 4b7bd27de2..33f4ee8624 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -470,6 +470,12 @@ rtc_source_set("test_support") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0103.patch b/third_party/libwebrtc/moz-patch-stack/s0103.patch @@ -75,7 +75,7 @@ index cdbd705ec2..4ee826ec58 100644 # The python interpreter to use by default. On Windows, this will look # for vpython3.exe and vpython3.bat. diff --git a/BUILD.gn b/BUILD.gn -index 4501b6d714..fd7b8c0244 100644 +index 9ebcd0de52..9a5730ab4c 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -21,15 +21,15 @@ @@ -107,7 +107,7 @@ index 4501b6d714..fd7b8c0244 100644 defines = [] deps = [ -@@ -854,7 +854,7 @@ rtc_static_library("dcsctp") { +@@ -853,7 +853,7 @@ rtc_static_library("dcsctp") { visibility = [ "//:default" ] sources = [] complete_static_lib = true @@ -116,7 +116,7 @@ index 4501b6d714..fd7b8c0244 100644 defines = [] deps = [ "net/dcsctp/public:factory", -@@ -889,7 +889,7 @@ group("poison_software_video_codecs") { +@@ -888,7 +888,7 @@ group("poison_software_video_codecs") { if (!build_with_chromium) { # Write debug logs to gn_logs.txt. # This is also required for Siso builds. @@ -756,7 +756,7 @@ index 52efbf7c09..7461af4d7b 100644 import("../webrtc.gni") diff --git a/test/BUILD.gn b/test/BUILD.gn -index 6b73a8e345..f5367e350c 100644 +index 33f4ee8624..edd3e02d77 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -6,10 +6,10 @@ @@ -772,7 +772,7 @@ index 6b73a8e345..f5367e350c 100644 import("//third_party/jni_zero/jni_zero.gni") } -@@ -415,7 +415,7 @@ if (is_ios) { +@@ -415,7 +415,7 @@ if (is_ios && !build_with_chromium) { testonly = true visibility = [ "*" ] sources = [ "ios/google_test_runner.mm" ] diff --git a/third_party/libwebrtc/moz-patch-stack/s0106.patch b/third_party/libwebrtc/moz-patch-stack/s0106.patch @@ -9,10 +9,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/90a33b06e51017d25 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn -index fd7b8c0244..361c87410f 100644 +index 9a5730ab4c..a89b2e964b 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -566,6 +566,7 @@ if (!build_with_chromium) { +@@ -565,6 +565,7 @@ if (!build_with_chromium) { "call", "common_audio", "common_video", @@ -20,7 +20,7 @@ index fd7b8c0244..361c87410f 100644 "logging:rtc_event_log_api", "media", "modules", -@@ -851,7 +852,7 @@ if (rtc_include_tests && !build_with_chromium) { +@@ -850,7 +851,7 @@ if (rtc_include_tests && !build_with_chromium) { # Build target for standalone dcsctp rtc_static_library("dcsctp") { # Only the root target should depend on this. diff --git a/third_party/libwebrtc/moz-patch-stack/s0108.patch b/third_party/libwebrtc/moz-patch-stack/s0108.patch @@ -16,7 +16,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/4527c41ef71d7683c 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/BUILD.gn b/BUILD.gn -index 361c87410f..c23971970b 100644 +index a89b2e964b..c287c476df 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -521,6 +521,9 @@ if (!rtc_build_ssl) { @@ -29,7 +29,7 @@ index 361c87410f..c23971970b 100644 } } -@@ -617,6 +620,7 @@ if (!build_with_chromium) { +@@ -616,6 +619,7 @@ if (!build_with_chromium) { "api/environment:environment_factory", "api/video:video_frame", "api/video:video_rtp_headers", diff --git a/third_party/libwebrtc/moz-patch-stack/s0112.patch b/third_party/libwebrtc/moz-patch-stack/s0112.patch @@ -10,10 +10,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/27c29807e6f46562d 1 file changed, 1 insertion(+) diff --git a/BUILD.gn b/BUILD.gn -index c23971970b..636e47bef8 100644 +index c287c476df..db45ec0415 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -617,6 +617,7 @@ if (!build_with_chromium) { +@@ -616,6 +616,7 @@ if (!build_with_chromium) { if (build_with_mozilla) { deps += [ diff --git a/third_party/libwebrtc/moz-patch-stack/s0129.patch b/third_party/libwebrtc/moz-patch-stack/s0129.patch @@ -9,7 +9,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/43de54a6e52daf0a0 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn -index 636e47bef8..d338e4cb0d 100644 +index db45ec0415..3bf708728f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -315,6 +315,17 @@ config("common_config") { diff --git a/third_party/libwebrtc/rtc_tools/BUILD.gn b/third_party/libwebrtc/rtc_tools/BUILD.gn @@ -140,12 +140,13 @@ if (!is_component_build) { ":video_file_reader", ":video_file_writer", ":video_quality_analysis", + "../api:array_view", "../api:make_ref_counted", "../api:scoped_refptr", "../api/test/metrics:chrome_perf_dashboard_metrics_exporter", "../api/test/metrics:global_metrics_logger_and_exporter", + "../api/test/metrics:metric", "../api/test/metrics:metrics_exporter", - "../api/test/metrics:stdout_metrics_exporter", "../rtc_base:stringutils", "//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/flags:parse", diff --git a/third_party/libwebrtc/rtc_tools/frame_analyzer/frame_analyzer.cc b/third_party/libwebrtc/rtc_tools/frame_analyzer/frame_analyzer.cc @@ -8,10 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ - +#include <cmath> #include <cstddef> #include <cstdint> #include <cstdio> +#include <cstdlib> #include <memory> #include <string> #include <utility> @@ -20,11 +21,12 @@ #include "absl/flags/flag.h" #include "absl/flags/parse.h" #include "absl/strings/match.h" +#include "api/array_view.h" #include "api/scoped_refptr.h" #include "api/test/metrics/chrome_perf_dashboard_metrics_exporter.h" #include "api/test/metrics/global_metrics_logger_and_exporter.h" +#include "api/test/metrics/metric.h" #include "api/test/metrics/metrics_exporter.h" -#include "api/test/metrics/stdout_metrics_exporter.h" #include "rtc_base/strings/string_builder.h" #include "rtc_tools/frame_analyzer/video_color_aligner.h" #include "rtc_tools/frame_analyzer/video_geometry_aligner.h" @@ -75,6 +77,98 @@ std::string JoinFilename(std::string directory, std::string filename) { return directory + kPathDelimiter + filename; } +// FrameAnalyzerMetricsExporter is a fork of +// webrtc::test::StdoutMetricsExporter. The fork was required because: +// 1. frame_analyzer must be compiled with build_with_chromium=true +// 2. The api/metrics:stdout_metrics_exporter depends on absl/flags which cannot +// be build when build_with_chromium=true unless the target is an +// rtc_executable (which is not the case for +// api/metrics:stdout_metrics_exporter). So this fork allows to cut the +// dependency. + +// Returns positive integral part of the number. +int64_t IntegralPart(double value) { + return std::lround(std::floor(std::abs(value))); +} + +void AppendWithPrecision(double value, + int digits_after_comma, + webrtc::StringBuilder& out) { + int64_t multiplier = std::lround(std::pow(10, digits_after_comma)); + int64_t integral_part = IntegralPart(value); + double decimal_part = std::abs(value) - integral_part; + + // If decimal part has leading zeros then when it will be multiplied on + // `multiplier`, leading zeros will be lost. To preserve them we add "1" + // so then leading digit will be greater than 0 and won't be removed. + // + // During conversion to the string leading digit has to be stripped. + // + // Also due to rounding it may happen that leading digit may be incremented, + // like with `digits_after_comma` 3 number 1.9995 will be rounded to 2. In + // such case this increment has to be propagated to the `integral_part`. + int64_t decimal_holder = std::lround((1 + decimal_part) * multiplier); + if (decimal_holder >= 2 * multiplier) { + // Rounding incremented added leading digit, so we need to transfer 1 to + // integral part. + integral_part++; + decimal_holder -= multiplier; + } + // Remove trailing zeros. + while (decimal_holder % 10 == 0) { + decimal_holder /= 10; + } + + // Print serialized number to output. + if (value < 0) { + out << "-"; + } + out << integral_part; + if (decimal_holder != 1) { + out << "." << std::to_string(decimal_holder).substr(1, digits_after_comma); + } +} + +class FrameAnalyzerMetricsExporter : public webrtc::test::MetricsExporter { + public: + FrameAnalyzerMetricsExporter() : output_(stdout) {} + ~FrameAnalyzerMetricsExporter() override = default; + + FrameAnalyzerMetricsExporter(const FrameAnalyzerMetricsExporter&) = delete; + FrameAnalyzerMetricsExporter& operator=(const FrameAnalyzerMetricsExporter&) = + delete; + + bool Export(webrtc::ArrayView<const webrtc::test::Metric> metrics) override { + for (const webrtc::test::Metric& metric : metrics) { + PrintMetric(metric); + } + return true; + } + + private: + void PrintMetric(const webrtc::test::Metric& metric) { + webrtc::StringBuilder value_stream; + value_stream << metric.test_case << " / " << metric.name << "= {mean="; + if (metric.stats.mean.has_value()) { + AppendWithPrecision(*metric.stats.mean, 8, value_stream); + } else { + value_stream << "-"; + } + value_stream << ", stddev="; + if (metric.stats.stddev.has_value()) { + AppendWithPrecision(*metric.stats.stddev, 8, value_stream); + } else { + value_stream << "-"; + } + value_stream << "} " << ToString(metric.unit) << " (" + << ToString(metric.improvement_direction) << ")"; + + fprintf(output_, "RESULT: %s\n", value_stream.str().c_str()); + } + + FILE* const output_; +}; + } // namespace /* @@ -168,7 +262,7 @@ int main(int argc, char* argv[]) { *webrtc::test::GetGlobalMetricsLogger()); std::vector<std::unique_ptr<webrtc::test::MetricsExporter>> exporters; - exporters.push_back(std::make_unique<webrtc::test::StdoutMetricsExporter>()); + exporters.push_back(std::make_unique<FrameAnalyzerMetricsExporter>()); std::string chartjson_result_file = absl::GetFlag(FLAGS_chartjson_result_file); if (!chartjson_result_file.empty()) { diff --git a/third_party/libwebrtc/test/BUILD.gn b/third_party/libwebrtc/test/BUILD.gn @@ -380,7 +380,7 @@ rtc_library("perf_test") { } } -if (is_ios) { +if (is_ios && !build_with_chromium) { rtc_library("test_support_objc") { testonly = true visibility = [ @@ -459,7 +459,7 @@ rtc_source_set("test_support") { "gtest.h", ] - if (is_ios) { + if (is_ios && !build_with_chromium) { public_deps += # no-presubmit-check TODO(webrtc:8603) [ ":test_support_objc" ] }