From 5023ffbb38b4965d2859e667152777250d5ea30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Mon, 4 Jul 2022 15:47:25 +0200 Subject: [PATCH] DCHECK that RTCStatsCollector does not block-invoke more than twice. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the modern getStats implementation, we currently do two block-invokes when we trigger stats collection, once for signaling -> worker and once for signaling -> network inside, both take place inside the "prepare" method: RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n. For comparison, the legacy stats collector currently require 4 block invokes to operate. Bug: webrtc:14247 Change-Id: Ie739cbcf29d87041484183b520aeba520aafcaba Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/267660 Reviewed-by: Harald Alvestrand Commit-Queue: Henrik Boström Cr-Commit-Position: refs/heads/main@{#37424} --- pc/peer_connection.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index 3bd62c89f3..b112099c2b 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -1241,6 +1241,7 @@ void PeerConnection::GetStats(RTCStatsCollectorCallback* callback) { RTC_LOG_THREAD_BLOCK_COUNT(); stats_collector_->GetStatsReport( rtc::scoped_refptr(callback)); + RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(2); } void PeerConnection::GetStats( @@ -1250,6 +1251,7 @@ void PeerConnection::GetStats( RTC_DCHECK_RUN_ON(signaling_thread()); RTC_DCHECK(callback); RTC_DCHECK(stats_collector_); + RTC_LOG_THREAD_BLOCK_COUNT(); rtc::scoped_refptr internal_sender; if (selector) { for (const auto& proxy_transceiver : @@ -1271,6 +1273,7 @@ void PeerConnection::GetStats( // selector" is an empty set. Invoking GetStatsReport() with a null selector // produces an empty stats report. stats_collector_->GetStatsReport(internal_sender, callback); + RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(2); } void PeerConnection::GetStats( @@ -1280,6 +1283,7 @@ void PeerConnection::GetStats( RTC_DCHECK_RUN_ON(signaling_thread()); RTC_DCHECK(callback); RTC_DCHECK(stats_collector_); + RTC_LOG_THREAD_BLOCK_COUNT(); rtc::scoped_refptr internal_receiver; if (selector) { for (const auto& proxy_transceiver : @@ -1301,6 +1305,7 @@ void PeerConnection::GetStats( // the selector" is an empty set. Invoking GetStatsReport() with a null // selector produces an empty stats report. stats_collector_->GetStatsReport(internal_receiver, callback); + RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(2); } PeerConnectionInterface::SignalingState PeerConnection::signaling_state() {