tor-browser

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

commit f0598164d8d30a9a882a8d0a393b42fca8cef389
parent 4e09c97ded537e8b960a6738f3aa09794ea4cc97
Author: Chun-Min Chang <chun.m.chang@gmail.com>
Date:   Tue, 30 Sep 2025 23:43:40 +0000

Bug 1987888 - Reduce frames in 4K MediaDataEncoder tests to prevent timeout r=jolin

This patch reduces the number of frames used in MediaDataEncoder's 4K
gtests to work around the timeout issues and speed up the test
execution.

Encoding 4K (or larger) frames can take significant time. On my local
machine, each 4K test takes about 6-8 seconds, and with 8 such tests,
the total runtime becomes substantial.

By lowering the number of frames processed in these tests, we should be
able to reduce overall runtime and avoid hitting timeouts.

Differential Revision: https://phabricator.services.mozilla.com/D265656

Diffstat:
Mdom/media/gtest/TestMediaDataEncoder.cpp | 20++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/dom/media/gtest/TestMediaDataEncoder.cpp b/dom/media/gtest/TestMediaDataEncoder.cpp @@ -434,14 +434,16 @@ static void H264EncodesTest(Usage aUsage, aUsage, EncoderConfig::SampleFormat(dom::ImageBitmapFormat::YUV420P), aFrameSource.GetSize(), ScalabilityMode::None, aSpecific); EXPECT_TRUE(EnsureInit(e)); + const bool is4KOrLarger = kImageSize4K <= aFrameSource.GetSize(); + const size_t numFrames = NUM_FRAMES / (is4KOrLarger ? 3 : 1); EncodeResult r = GET_OR_RETURN_ON_ERROR( - EncodeWithInputStats(e, NUM_FRAMES, aFrameSource)); + EncodeWithInputStats(e, numFrames, aFrameSource)); output = std::move(r.mEncodedData); - if (aUsage == Usage::Realtime && kImageSize4K <= aFrameSource.GetSize()) { + if (aUsage == Usage::Realtime && is4KOrLarger) { // Realtime encoding may drop frames for large frame sizes. - EXPECT_LE(output.Length(), NUM_FRAMES); + EXPECT_LE(output.Length(), numFrames); } else { - EXPECT_EQ(output.Length(), NUM_FRAMES); + EXPECT_EQ(output.Length(), numFrames); } EXPECT_GE(GetKeyFrameCount(output), r.mInputKeyframes); if (isAVCC) { @@ -519,15 +521,17 @@ static void H264EncodeBatchTest( aFrameSource.GetSize(), ScalabilityMode::None, aSpecific); EXPECT_TRUE(EnsureInit(e)); + const bool is4KOrLarger = kImageSize4K <= aFrameSource.GetSize(); + const size_t numFrames = NUM_FRAMES / (is4KOrLarger ? 3 : 1); constexpr size_t batchSize = 6; EncodeResult r = GET_OR_RETURN_ON_ERROR( - EncodeBatchWithInputStats(e, NUM_FRAMES, aFrameSource, batchSize)); + EncodeBatchWithInputStats(e, numFrames, aFrameSource, batchSize)); MediaDataEncoder::EncodedData output = std::move(r.mEncodedData); - if (aUsage == Usage::Realtime && kImageSize4K <= aFrameSource.GetSize()) { + if (aUsage == Usage::Realtime && is4KOrLarger) { // Realtime encoding may drop frames for large frame sizes. - EXPECT_LE(output.Length(), NUM_FRAMES); + EXPECT_LE(output.Length(), numFrames); } else { - EXPECT_EQ(output.Length(), NUM_FRAMES); + EXPECT_EQ(output.Length(), numFrames); } EXPECT_GE(GetKeyFrameCount(output), r.mInputKeyframes); if (isAVCC) {