Skip to content

Commit c2ffdee

Browse files
TommiWebRTC LUCI CQ
authored andcommitted
Remove blocking calls from the stats gathering path in RTCStatsCollector
Improve tests for CancelPendingRequestAndGetShutdownTasks to more accurately simulate multithreaded shutdown. Any pending operations are cancelled as before, but CancelPendingRequestAndGetShutdownTasks will now optionally issue the pending callbacks immediately while also canceling pending async operations without blocking. Remove WaitForPendingRequest which was previously called from PC::Close. The dependency on the transport controller is not a concern anymore. * Introduce `worker_safety_` to guard tasks running on the worker thread. * Refactor `PrepareTransceiverStatsInfosAndCallStats_s_w` to return an `absl::AnyInvocable` and pass data via function arguments instead of storing intermediate results in `collection_context_`. * Remove `network_report_event_` as manual synchronization is no longer needed. * Ensure pending requests receive callbacks immediately during shutdown or are safely dropped if the collector is destroyed. Bug: webrtc:42222804 Change-Id: Ibb576e46dfa77e95c072d99282f6780a6df46458 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/443460 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#46747}
1 parent c311a00 commit c2ffdee

6 files changed

Lines changed: 237 additions & 193 deletions

pc/peer_connection.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,8 @@ PeerConnection::~PeerConnection() {
695695
sdp_handler_->GetMediaChannelTeardownTasks(network_tasks, worker_tasks);
696696

697697
legacy_stats_.reset(nullptr);
698-
network_tasks.push_back(
699-
stats_collector_.CancelPendingRequestAndGetShutdownTask());
698+
stats_collector_.CancelPendingRequestAndGetShutdownTasks(network_tasks,
699+
worker_tasks);
700700

701701
CloseOnNetworkThread(network_tasks);
702702

@@ -1925,9 +1925,6 @@ void PeerConnection::Close() {
19251925
transceiver->StopInternal();
19261926
}
19271927
}
1928-
// Ensure that all asynchronous stats requests are completed before destroying
1929-
// the transport controller below.
1930-
stats_collector_.WaitForPendingRequest();
19311928

19321929
// Don't destroy BaseChannels until after stats has been cleaned up so that
19331930
// the last stats request can still read from the channels.

0 commit comments

Comments
 (0)