From 5145d90660a575324815dce4c826193f35c4f1d6 Mon Sep 17 00:00:00 2001 From: Markus Handell Date: Fri, 3 Mar 2023 16:35:35 +0100 Subject: [PATCH] NackRequester::ClearUpTo: avoid PostTasks. Under the combined network/worker thread project, tasks are unnecessarily posted to the same thread. Avoid this by posting only if invoked on a diffferent sequence. TESTED=presubmit + local Meet calls. Bug: chromium:1373439 Change-Id: I2ca15b2c725f412ca8a0b8132d6b221f9f6b6032 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295868 Reviewed-by: Harald Alvestrand Reviewed-by: Tomas Gunnarsson Commit-Queue: Markus Handell Cr-Commit-Position: refs/heads/main@{#39477} --- modules/video_coding/nack_requester.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/video_coding/nack_requester.cc b/modules/video_coding/nack_requester.cc index 4e74032d01..008420f4da 100644 --- a/modules/video_coding/nack_requester.cc +++ b/modules/video_coding/nack_requester.cc @@ -14,7 +14,6 @@ #include #include "api/sequence_checker.h" -#include "api/task_queue/task_queue_base.h" #include "api/units/timestamp.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/field_trial_parser.h" @@ -219,15 +218,17 @@ int NackRequester::OnReceivedPacket(uint16_t seq_num, } void NackRequester::ClearUpTo(uint16_t seq_num) { - // Called via RtpVideoStreamReceiver2::FrameContinuous on the network thread. - worker_thread_->PostTask(SafeTask(task_safety_.flag(), [seq_num, this]() { - RTC_DCHECK_RUN_ON(worker_thread_); - nack_list_.erase(nack_list_.begin(), nack_list_.lower_bound(seq_num)); - keyframe_list_.erase(keyframe_list_.begin(), - keyframe_list_.lower_bound(seq_num)); - recovered_list_.erase(recovered_list_.begin(), - recovered_list_.lower_bound(seq_num)); - })); + // TODO(bugs.webrtc.org/11993): This method is actually called on the worker + // thread even though the caller stack to this call passes thread checkers + // indicating they belong to the network thread. The inline execution below + // needs to be posted to the worker thread if callers migrate to the network + // thread. + RTC_DCHECK_RUN_ON(worker_thread_); + nack_list_.erase(nack_list_.begin(), nack_list_.lower_bound(seq_num)); + keyframe_list_.erase(keyframe_list_.begin(), + keyframe_list_.lower_bound(seq_num)); + recovered_list_.erase(recovered_list_.begin(), + recovered_list_.lower_bound(seq_num)); } void NackRequester::UpdateRtt(int64_t rtt_ms) {