Hunch that something might be broken wrt Thread and TQ

integration in Chromium.

Change-Id: I5322fce1e874412a6b0a21ce16902d8846bcaf74
Bug: webrtc:11572
Tbr: henrika@webrtc.org
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175041
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31247}
This commit is contained in:
Tommi 2020-05-13 21:26:37 +02:00 committed by Commit Bot
parent adaec45f36
commit 47173c9f60

View File

@ -19,6 +19,7 @@
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/task_utils/to_queued_task.h"
#include "rtc_base/thread.h"
#include "rtc_base/time_utils.h"
#include "system_wrappers/include/clock.h"
#include "system_wrappers/include/field_trial.h"
@ -81,6 +82,20 @@ std::string UmaSuffixForContentType(VideoContentType content_type) {
return ss.str();
}
// TODO(https://bugs.webrtc.org/11572): Workaround for an issue with some
// rtc::Thread instances and/or implementations that don't register as the
// current task queue.
bool IsCurrentTaskQueueOrThread(TaskQueueBase* task_queue) {
if (task_queue->IsCurrent())
return true;
rtc::Thread* current_thread = rtc::ThreadManager::Instance()->CurrentThread();
if (!current_thread)
return false;
return static_cast<TaskQueueBase*>(current_thread) == task_queue;
}
} // namespace
ReceiveStatisticsProxy::ReceiveStatisticsProxy(
@ -766,7 +781,7 @@ void ReceiveStatisticsProxy::RtcpPacketTypesCounterUpdated(
if (ssrc != remote_ssrc_)
return;
if (!worker_thread_->IsCurrent()) {
if (!IsCurrentTaskQueueOrThread(worker_thread_)) {
// RtpRtcp::Configuration has a single RtcpPacketTypeCounterObserver and
// that same configuration may be used for both receiver and sender
// (see ModuleRtpRtcpImpl::ModuleRtpRtcpImpl).