Skip to content

Fix RTCStatsCollector crash for stopped transceivers - #262

Merged
pblazej merged 1 commit into
m144_releasefrom
blaze/nw-thread-crash
Jul 6, 2026
Merged

pblazej merged 1 commit into
m144_releasefrom
blaze/nw-thread-crash

Conversation

@pblazej

@pblazej pblazej commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Backport of upstream 0b6045b38b ("Prevent RTCStatsCollector crash for stopped transceivers", M147). A getStats issued between transceiver.stopInternal() and the answer applying the rejected m-section prepares an RtpTransceiverStatsInfo with mid/transport_name set but an uninitialized TrackMediaInfoMap, so ProduceVideoRTPStreamStats_n dereferences the disengaged video_media_info() optional on the network thread (libc++ hardening abort in release, Check failed: is_initialized_ in debug). This adds the missing kStopped guard to ProduceRTPStreamStats_n plus the upstream regression test, which crashes before and passes after this change.

Resymbolicated crash stack (LiveKitWebRTC 144.7559.10; identical shape on 144.7559.08):

Thread name: network_thread — "optional:940 … operator-> called on a disengaged value"
3  LiveKitWebRTC  +0x941ae8  libc++ hardening assert → abort()
4  LiveKitWebRTC  +0x85ecbc  RTCStatsCollector::ProduceVideoRTPStreamStats_n  (video_media_info()->receivers)
5  LiveKitWebRTC  +0x85ad5c  RTCStatsCollector::ProduceRTPStreamStats_n  (loop over RtpTransceiverStatsInfo)
6  LiveKitWebRTC  +0x85a48c  RTCStatsCollector::ProducePartialResultsOnNetworkThread
7  LiveKitWebRTC  +0x860de4  absl::AnyInvocable thunk
8  LiveKitWebRTC             webrtc::Thread::Dispatch(absl::AnyInvocable<void () &&>) + 160

Fixes livekit/client-sdk-swift#1056

🤖 Generated with Claude Code

Backport of upstream 0b6045b (webrtc-review.googlesource.com/c/src/+/458680,
landed in M147). A getStats issued between transceiver.stopInternal() and the
answer applying the rejected m-section prepares an RtpTransceiverStatsInfo with
mid/transport_name set but no initialized TrackMediaInfoMap; the produce step on
the network thread then dereferences the disengaged media-info optional.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@pblazej
pblazej merged commit 9b1b768 into m144_release Jul 6, 2026
4 checks passed
@pblazej
pblazej deleted the blaze/nw-thread-crash branch July 6, 2026 06:59
cloudwebrtc pushed a commit that referenced this pull request Jul 16, 2026
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
sabahattinseven added a commit to sabahattinseven/client-sdk-android-fast-match that referenced this pull request Oct 3, 2026
Upstream v2.28.2 moved to 144.7559.14. The fork takes 144.7559.15, the last
m144 build, which adds livekit/libwebrtc#288 on top: prewarmRecording() and
requestStartRecording() return false instead of throwing AssertionError when
AudioRecord init failed. FastMatchSession prewarms the mic on every warm-up,
so that path is live here. The other three .15 backports are iOS/macOS-only.

Fixes relevant to fast-match that arrive with the .09 -> .15 delta:
- livekit/libwebrtc#262: RTCStatsCollector no longer dereferences a disengaged
  optional for a stopped transceiver (the network-thread SIGABRT class the SDK
  worked around with metrics-poll and teardown sequencing).
- livekit/libwebrtc#266: AudioRecord is no longer released under a live reader
  when the stop join times out on rapid capture stop/start cycles.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants