DCHECK that RTCStatsCollector does not block-invoke more than twice.

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 <hta@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37424}
This commit is contained in:
Henrik Boström 2022-07-04 15:47:25 +02:00 committed by WebRTC LUCI CQ
parent 0a72a28df8
commit 5023ffbb38

View File

@ -1241,6 +1241,7 @@ void PeerConnection::GetStats(RTCStatsCollectorCallback* callback) {
RTC_LOG_THREAD_BLOCK_COUNT();
stats_collector_->GetStatsReport(
rtc::scoped_refptr<RTCStatsCollectorCallback>(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<RtpSenderInternal> 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<RtpReceiverInternal> 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() {