Repository navigation
Expose dynacast for DataTracks - #323
stephen-derosa wants to merge 3 commits into
Conversation
Expose the Rust no-subscriber result and test pause and resume with a live server. Measure frame pushes with and without a subscriber.
There was a problem hiding this comment.
Note
Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.
🔍 Devin Review: 2 flags
Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
There was a problem hiding this comment.
🔵 Needs a closer look
The benchmark measures before subscriber-demand state settles, so dynacast runs with no subscribers can report enqueue or mixed costs instead of paused-path latency without a bounded warm-up and explicit legacy-server baseline or timeout handling.
No open issues 🎉
What changed in this PR
Prepares the C++ SDK to expose data-track dynacast through Rust’s NO_SUBSCRIBERS result, with pause/resume tests and benchmark measurements. Runtime support still requires compatible Rust and server releases.
Changes:
- Adds the public error code, protocol mapping, and caller guidance.
- Updates delivery and memory tests, and adds an opt-in dynacast integration test.
- Adds zero-subscriber benchmarking, push timing, and separate rejection counts.
| File | Description |
|---|---|
src/tests/unit/test_data_track_error.cpp |
Adds protocol mapping and message-preservation coverage. |
src/tests/memory/memory_tester.cpp |
Adds an active subscriber to preserve frame-enqueue coverage. |
src/tests/integration/test_data_track.cpp |
Tests pause/resume and unpublished-track behavior; tolerates subscription transitions. |
src/data_track_error.cpp |
Maps protocol value 5 to NO_SUBSCRIBERS. |
include/livekit/local_data_track.h |
Documents no-subscriber results and frame handling. |
include/livekit/data_track_error.h |
Exposes the new public error code. |
docs/testing.md |
Documents dynacast prerequisites and memory-test changes. |
data-track-dynacast-plan.md |
Records implementation plans and preview verification results. |
benchmarks/data_track_throughput/README.md |
Explains subscriber and zero-subscriber measurements. |
benchmarks/data_track_throughput/producer.cpp |
Adds zero-subscriber mode and push metrics. |
benchmarks/data_track_throughput/consumer.cpp |
Removes callback cleanup that could access an already-destroyed room. |
benchmarks/data_track_throughput/common.h |
Adds timing and rejection counters to producer statistics. |
Review effort: Balanced
There was a problem hiding this comment.
Devin Review found 4 new potential issues.
3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| @@ -1 +1 @@ | |||
| Subproject commit 2811b4be194b091868ed83cca0603842179fed36 | |||
| Subproject commit 84a7d969ffe0929621fe709808cb616bf6c1bc45 | |||
There was a problem hiding this comment.
🔴 Rejected data tracks remain published forever
After a rejected reconnect republish, on_sfu_publish_response leaves the data track in Republishing and discards its descriptor. isPublished() stays true, while every nonempty tryPush() returns QUEUE_FULL. Later reconnects cannot recover the discarded data track.
Learn more
The Rust republish response handler removes the descriptor before examining the response. Its error branch returns without notifying the track's state channel. Local track state checks then reject pushes as queue exhaustion, while publication status still treats the track as published. The manager no longer owns the descriptor, so another reconnect cannot retry it.
Example: A publisher loses its connection, rejoins with data publishing permission revoked, and receives a rejected republish response. The old track reports published indefinitely but delivers no further frames.
Recommended fix: Pin a Rust revision that sends PublishState::Unpublished before returning from the failed republish branch. Include a regression test that rejects republishing and checks publication status, push errors, and completion of the unpublish wait.
Was this helpful? React with 👍 or 👎 to provide feedback.
| @@ -1 +1 @@ | |||
| Subproject commit 2811b4be194b091868ed83cca0603842179fed36 | |||
| Subproject commit 84a7d969ffe0929621fe709808cb616bf6c1bc45 | |||
There was a problem hiding this comment.
🔴 Windows WebRTC errors can crash callers
On Windows with _HAS_EXCEPTIONS=0, std::runtime_error retains pointers into temporary error strings. CXX reads freed memory when translating WebRTC failures into Rust errors. Recoverable failures can therefore abort the host process.
Learn more
The pinned WebRTC error wrappers throw std::runtime_error(serialize_error(...)); the same pattern occurs in the sender, transceiver, SDP, factory, and frame-cryptor wrappers. Bridge compilation imports WebRTC's preprocessor definitions through webrtc_defines, including the Windows _HAS_EXCEPTIONS=0 configuration. In that MSVC STL configuration, runtime_error delegates to an exception constructor that stores the message pointer without owning it. The temporary serialized string dies during unwinding, before CXX copies what() into its Rust exception.
Example: A Windows application encounters a rejected RTP parameter update. Instead of returning the serialized WebRTC error, CXX copies a dangling message pointer and can abort or return corrupted error text.
Recommended fix: Pin a Rust revision that retains an owning exception type for all CXX error wrappers, or otherwise ensures each exception owns its message. Validate a failing WebRTC operation on Windows in both debug and release SDK builds.
Was this helpful? React with 👍 or 👎 to provide feedback.
| @@ -1 +1 @@ | |||
| Subproject commit 2811b4be194b091868ed83cca0603842179fed36 | |||
| Subproject commit 84a7d969ffe0929621fe709808cb616bf6c1bc45 | |||
There was a problem hiding this comment.
🟡 Rejected media publications stall ten seconds
When the server rejects AddTrack, on_signal_event no longer completes the pending media publication. add_track waits ten seconds for TrackPublished, then reports a generic timeout instead of the rejection.
Learn more
The request-response handler handles data-track publish errors but no longer resolves media publication failures. add_track registers a sender keyed by the track CID and waits for a successful TrackPublished event or TRACK_PUBLISH_TIMEOUT. A rejected AddTrack produces no successful publication event, so the caller waits the entire timeout even after receiving a definitive failure.
Example: An application publishes an audio track without publication permission. The server rejects it immediately, but publishTrack blocks for ten seconds and returns a timeout rather than the permission error.
Recommended fix: Pin a Rust revision that recognizes rejected AddTrack responses, removes the corresponding pending entry, and sends its error to the awaiting publication. Preserve the server's reason and message, and test rejection without waiting for the timeout.
Was this helpful? React with 👍 or 👎 to provide feedback.
| @@ -1 +1 @@ | |||
| Subproject commit 2811b4be194b091868ed83cca0603842179fed36 | |||
| Subproject commit 84a7d969ffe0929621fe709808cb616bf6c1bc45 | |||
There was a problem hiding this comment.
🟨 Muted publications re-enable local media transmission
Publishing a pre-muted audio or video track makes publish_track call track.enable() without clearing its muted flag. Native media becomes enabled despite the mute state. Server-side muting does not preserve the local privacy boundary.
Was this helpful? React with 👍 or 👎 to provide feedback.
Overview
Expose the Rust no-subscriber result and test pause and resume with a live server. Measure frame pushes with and without a subscriber.
Testing