Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes critical bug in WebRTC SDP renegotiation where active track receivers were incorrectly marked as "NOT HANDLED" during subsequent negotiations, causing media flow disruption in mesh topology scenarios.
The fix adds context-aware receiver handling to distinguish between initial negotiation (where skipping active receivers prevents duplicates) and renegotiation (where active receivers represent existing media flows to preserve per RFC 8829).
Problem Description
Symptoms
During SDP renegotiation in mesh topologies (3+ peers), the following issues occurred:
Example Log Output (Before Fix):
These warnings appeared during renegotiation for tracks that were actually flowing correctly.
Reproduction Steps
Root Cause
The
start_rtp_receivers()function inpeer_connection_internal.rschecked if a receiver had already started receiving:The Bug: This check did NOT distinguish between:
During renegotiation, the same tracks (SSRCs) appear in the new SDP offer per RFC 8829 Section 3.7's requirement to "reuse existing media descriptions". The receiver is already active and receiving data. The code incorrectly skipped these receivers, marking them as "NOT HANDLED" instead of recognizing they are already properly established.
Why This Happens:
In mesh topologies:
The logic flaw:
This means active receivers are skipped during renegotiation, never reaching the "track_handled = true" logic.
Solution
Code Changes
File Modified:
webrtc/src/peer_connection/peer_connection_internal.rsFunction:
start_rtp_receivers()Change 1: Add
is_renegotiationparameterChange 2: Skip SSRC filtering during renegotiation
Change 3: Context-aware receiver handling
How It Works
Initial Negotiation (
is_renegotiation=false):Renegotiation (
is_renegotiation=true):RFC 8829 Compliance
Per RFC 8829 Section 3.7 (Subsequent Offers and Answers):
This fix implements the "reuse existing media descriptions" requirement by recognizing that active receivers during renegotiation represent existing, valid media flows that should continue uninterrupted.
Testing
Bug Reproducer Test
File:
webrtc/src/peer_connection/peer_connection_test.rsTest:
test_receiver_reuse_during_renegotiation_issue_749()Size: 270 lines with comprehensive documentation
Test Flow:
Test Documentation:
The test includes comprehensive 5-section documentation following best practices:
Test Results:
Full Test Suite
All existing tests pass with no regressions:
Quality Checks
Clippy (strict warnings):
✅ PASSED (no warnings)
Formatting:
✅ PASSED (compliant with rustfmt)
Compilation:
✅ PASSED (no errors)
Impact Assessment
Severity
High - Affects all mesh topology deployments with 3+ peers where renegotiation occurs.
Breaking Changes
None - The fix is fully backward compatible.
Changes are internal to
start_rtp_receivers()and do not affect public API:Performance
Zero overhead - Single boolean check with no runtime cost.
The
is_renegotiationparameter is a compile-time boolean that enables different code paths. No additional allocations, locks, or computational overhead introduced.Affected Use Cases
Fixes (Critical):
Unchanged (No Impact):
Production Validation
This fix has been validated in production on a fork and resolves all observed mesh topology renegotiation failures. No adverse effects or regressions observed.
Migration Guide
For Users
No action required. The fix is transparent and automatically handles both initial negotiation and renegotiation correctly.
For Maintainers
If extending
start_rtp_receivers()or related negotiation code, ensure:have_received()context before flow control decisionsChecklist
Related
Issue
RFC References
Key Quote from RFC 8829
This confirms that existing tracks appearing in renegotiation SDPs is expected behavior per the WebRTC specification.