From 879f5a34a587551df23e970a587dccacaebda8cd Mon Sep 17 00:00:00 2001 From: Ilya Nikolaevskiy Date: Thu, 31 May 2018 09:47:17 +0200 Subject: [PATCH] Add test against crashes in VideoQualityObserver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If there were a lot of pauses in the receive video stream, it may've caused a crash because of a null rtc::Optional dereferencing. This is the test reproducing that behaviour. Bug: webrtc:9338 Change-Id: I1cef72a88a54f762ef27665d372e4a1d1225e059 Reviewed-on: https://webrtc-review.googlesource.com/80161 Reviewed-by: Erik Språng Commit-Queue: Ilya Nikolaevskiy Cr-Commit-Position: refs/heads/master@{#23470} --- video/receive_statistics_proxy_unittest.cc | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/video/receive_statistics_proxy_unittest.cc b/video/receive_statistics_proxy_unittest.cc index f61f0865ac..c3bc458848 100644 --- a/video/receive_statistics_proxy_unittest.cc +++ b/video/receive_statistics_proxy_unittest.cc @@ -1046,6 +1046,33 @@ TEST_P(ReceiveStatisticsProxyTest, PausesAreIgnored) { } } +TEST_P(ReceiveStatisticsProxyTest, ManyPausesAtTheBeginning) { + const VideoContentType content_type = GetParam(); + const int kInterFrameDelayMs = 33; + const int kPauseDurationMs = 10000; + for (int i = 0; i <= kMinRequiredSamples; ++i) { + statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + content_type); + fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); + + statistics_proxy_->OnStreamInactive(); + fake_clock_.AdvanceTimeMilliseconds(kPauseDurationMs); + + statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + content_type); + fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); + } + + statistics_proxy_.reset(); + // No freezes should be detected, as all long inter-frame delays were pauses. + if (videocontenttypehelpers::IsScreenshare(content_type)) { + EXPECT_EQ(-1, metrics::MinSample( + "WebRTC.Video.Screenshare.MeanFreezeDurationMs")); + } else { + EXPECT_EQ(-1, metrics::MinSample("WebRTC.Video.MeanFreezeDurationMs")); + } +} + TEST_P(ReceiveStatisticsProxyTest, TimeInHdReported) { const VideoContentType content_type = GetParam(); const int kInterFrameDelayMs = 20;