From 0a3ad1a561ceda2301be0f6d92edb2a83883109d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Tue, 4 Apr 2023 15:35:54 +0200 Subject: [PATCH] Deflake simulcast flow tests: stop fake source for reals. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The FakePeriodicVideoSource was not actually stopping its repeated handle, which takes a raw pointer to the task queue. There could be a race here where a repeated task was being posted at the same time as the task queue was being destroyed due to the scoped safety flag being tied to the repeated task rather than the task queue. I'm still unable to repro locally, so this is a speculative fix. # No need to wait for ios/android bots, all other bots green NOTRY=True Bug: webrtc:15018 Change-Id: Id6f9bda5f4fc641abc11068f5cf8aa0f1cf36d27 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/300264 Reviewed-by: Jeremy Leconte Commit-Queue: Henrik Boström Cr-Commit-Position: refs/heads/main@{#39758} --- pc/test/fake_periodic_video_source.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pc/test/fake_periodic_video_source.h b/pc/test/fake_periodic_video_source.h index 407811578c..452a8f6c30 100644 --- a/pc/test/fake_periodic_video_source.h +++ b/pc/test/fake_periodic_video_source.h @@ -49,14 +49,15 @@ class FakePeriodicVideoSource final frame_source_.SetRotation(config.rotation); TimeDelta frame_interval = TimeDelta::Millis(config.frame_interval_ms); - RepeatingTaskHandle::Start(task_queue_->Get(), [this, frame_interval] { - if (broadcaster_.wants().rotation_applied) { - broadcaster_.OnFrame(frame_source_.GetFrameRotationApplied()); - } else { - broadcaster_.OnFrame(frame_source_.GetFrame()); - } - return frame_interval; - }); + repeating_task_handle_ = + RepeatingTaskHandle::Start(task_queue_->Get(), [this, frame_interval] { + if (broadcaster_.wants().rotation_applied) { + broadcaster_.OnFrame(frame_source_.GetFrameRotationApplied()); + } else { + broadcaster_.OnFrame(frame_source_.GetFrame()); + } + return frame_interval; + }); } rtc::VideoSinkWants wants() const { @@ -81,6 +82,7 @@ class FakePeriodicVideoSource final void Stop() { RTC_DCHECK(task_queue_); + task_queue_->SendTask([&]() { repeating_task_handle_.Stop(); }); task_queue_.reset(); } @@ -93,6 +95,7 @@ class FakePeriodicVideoSource final rtc::VideoSinkWants wants_ RTC_GUARDED_BY(&mutex_); std::unique_ptr task_queue_; + RepeatingTaskHandle repeating_task_handle_; }; } // namespace webrtc