Skip to content

Conversation

@ladvoc
Copy link
Contributor

@ladvoc ladvoc commented Aug 6, 2025

Summary of changes:

  • Implement data channel reliability improvements from other SDKs:
  • Refactor handling of incoming data packets
    • Take value enum out of packet to avoid large clones
    • Prefer packet level participant info fields over deprecated user packet fields
  • Retain local participant info in session layer
    • Ensure all outgoing data packets have their participant SID and identity fields set
  • End-to-end testing: introduce testing with a LiveKit server
    • Utilities for reading configuration from environment, creating multiple room connections
    • Test case to evaluate reliable data channel performance
    • Enable in CI (macOS and Linux only)

@ladvoc ladvoc force-pushed the ladvoc/dc-reliability branch from fd561d6 to 38d4f36 Compare August 19, 2025 07:13
@ladvoc ladvoc marked this pull request as ready for review August 19, 2025 12:24
ladvoc added 19 commits August 28, 2025 14:34
Use system time and duration

Add iterator method

Organize

Doc

Add cleanup
- Root kind field applying to all event types
- Detail enum
- Optional completion tx channel
- Prefer named fields
- Publish data request gets its own type
- Prefer packet level participant identity and SID for user packet
- Take packet value to avoid many unnecessary clones
Ensure all outgoing data packets have their participant identity and SID fields set by handling this as a low-level protocol detail in session
Install and run a LiveKit server before running tests
@ladvoc ladvoc force-pushed the ladvoc/dc-reliability branch from 38d4f36 to 1993355 Compare August 28, 2025 11:21
@ladvoc ladvoc force-pushed the ladvoc/dc-reliability branch from 0e26219 to 9710265 Compare August 28, 2025 11:57
@ladvoc ladvoc changed the title Reliable data channel Data channel reliability Aug 28, 2025
@ladvoc ladvoc requested review from bcherry and davidzhao August 28, 2025 12:13
@ladvoc
Copy link
Contributor Author

ladvoc commented Aug 28, 2025

Once this is merged, I will update Python.

@bcherry bcherry requested a review from cnderrauber August 28, 2025 17:28
Copy link
Contributor

@bcherry bcherry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm but would be good for @cnderrauber to confirm as well

self._send_until_threshold(threshold, &mut reliable_buffered_amount, &mut reliable_queue);
self._send_until_threshold(DataPacketKind::Reliable, threshold, &mut reliable_buffered_amount, &mut reliable_queue);
// TODO: Ensure this is the proper quantity
let retry_min_amount = (threshold as usize * 5) / 4; // threshold * 1.25

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In js client it is the size of buffered messages (sent but not acked by sfu) to avoid lost message during reconnecting, is the threshold same as the js client?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The threshold I used here was taken from the Swift implementation (DataChannelPair.swift:375); I will take a look at how this is handled in JS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cnderrauber, I did some stress testing, and it looks like the packet loss observed in Swift during testing cannot be reproduced in Rust, so I've gone ahead and removed the additional buffering.

Copy link

@cnderrauber cnderrauber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

@ladvoc ladvoc merged commit ac1952f into main Sep 9, 2025
16 of 19 checks passed
@ladvoc ladvoc deleted the ladvoc/dc-reliability branch September 9, 2025 05:46
@github-actions github-actions bot mentioned this pull request Sep 9, 2025
@ladvoc ladvoc mentioned this pull request Sep 23, 2025
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.

4 participants