Skip to content

WebRTC Bug Fixes, Diagnostics, and Backpressure#17

Open
timwu20 wants to merge 10 commits intohaiko-webrtc-multistream-nego-fix-3from
tim/impl-webrtc-roadmap
Open

WebRTC Bug Fixes, Diagnostics, and Backpressure#17
timwu20 wants to merge 10 commits intohaiko-webrtc-multistream-nego-fix-3from
tim/impl-webrtc-roadmap

Conversation

@timwu20
Copy link
Copy Markdown
Collaborator

@timwu20 timwu20 commented Mar 4, 2026

Stacked on top of paritytech/litep2p#554 (haiko's multistream-select negotiation fix). These changes address several issues discovered during testing with browser clients (smoldot) and improve reliability of the WebRTC transport.

Changes

Bug Fixes:

  • Fix InputRejected error during ICE negotiation (594520e) — Route all packets from existing opening connections to those connections instead of creating duplicate Rtc instances. Remove premature accepts() check that was rejecting valid packets before ICE candidate nomination completed.
  • Fix FIN-after-handler-drop race (130a647) — When a request-response handler writes a response and drops the Substream, a subsequent FIN from the remote peer no longer causes EssentialTaskClosed. Adds fin_delivered tracking to distinguish clean closes from unclean drops, emitting ResetStream only when appropriate.
  • Report substream open failure (d51dd01) — When a data channel closes during DCEP or multistream-select negotiation, report the failure to the protocol layer so it can retry instead of silently losing the substream.
  • Close substream before sending feedback (e72cd9d) — In request-response, call substream.close() before sending the feedback oneshot, ensuring the FIN is sent before the caller is notified of success.
  • Return error when SCTP write buffer is full (ce6d2ae) — channel.write() returns Ok(false) when the buffer is full; previously the bool was silently discarded, causing data loss. Now returns Error::ChannelClogged.

Backpressure:

  • Add network-level backpressure (be4c14b) — When channel.write() rejects data (global 128 KB SCTP buffer full), apply backpressure to the Substream's AsyncWrite impl so writers block instead of losing data. Pending writes are queued and retried.
  • Retry pending writes on Output::Transmit (4cefe69) — Replace per-channel ChannelBufferedAmountLow event with retry on Output::Transmit, which correctly handles the mismatch between str0m's global buffer limit and per-channel events.

Diagnostics:

  • Add trace logging for notification handshake (99498b8) — Trace-level logging for handshake negotiation flow: payload forwarding, handshake reads, and timeout reporting.

Dependency:

  • Update str0m to ChainSafe fork (8a7082f) — Migrate to ChainSafe's str0m fork with updated DTLS cert API and Rtc::builder().build(Instant::now()).

Test plan

  • All 328 unit tests pass (cargo test --features webrtc --lib)
  • rustfmt (nightly) clean
  • clippy clean
  • Verify large responses (>128 KB) are no longer truncated with backpressure

@timwu20 timwu20 force-pushed the tim/impl-webrtc-roadmap branch 2 times, most recently from 9db0cda to d218c6a Compare March 16, 2026 23:02
@timwu20 timwu20 force-pushed the tim/impl-webrtc-roadmap branch 2 times, most recently from 2d2e257 to dbc1e29 Compare March 25, 2026 21:44
@timwu20 timwu20 force-pushed the tim/impl-webrtc-roadmap branch from dbc1e29 to 3a074bb Compare March 25, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant