Repository navigation
Conversation
|
|
There was a problem hiding this comment.
Devin Review found 3 potential issues.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| req = proto_ffi.FfiRequest() | ||
| req.enable_remote_track_publication.track_publication_handle = self._ffi_handle.handle | ||
| req.enable_remote_track_publication.enabled = enabled | ||
| FfiClient.instance.request(req) |
There was a problem hiding this comment.
🔴 Track toggle crashes during unpublish
When a publisher removes a track during set_enabled, the native toggle can unwrap a track that no longer exists. The FFI panic callback terminates the Python process.
Learn more
The native request handler forwards the toggle to the Rust publication. The Rust method checks for an attached media track, checks whether that track is enabled, then reads the track again and unwraps it. Each lookup takes a separate read lock in track. A publisher can unpublish concurrently, and unpublish_track_inner clears the track. The native C bridge catches the resulting panic and forwards it to the Python callback, which sends SIGTERM.
Example: An agent pauses an incoming microphone while the other participant stops publishing it. If the unpublish clears the track after the enabled check but before the final lookup, the agent process exits instead of ignoring the toggle on the removed track.
Recommended fix: Fix the pinned Rust implementation to take one optional track snapshot, return if it is absent, and compare and update that snapshot with the requested value. Verify whether signaling also needs synchronization with detach. A Python subscribed check cannot close the native race.
Was this helpful? React with 👍 or 👎 to provide feedback.
| req.enable_remote_track_publication.enabled = enabled | ||
| FfiClient.instance.request(req) |
There was a problem hiding this comment.
🔴 Stale pause overrides track resume
Successive set_enabled calls spawn separate signaling tasks, so a pause can reach the server after its matching resume. The native toggle skips another resume because the local track already reads as enabled.
Learn more
The native toggle changes the local track synchronously but spawns each server update independently. The tasks run on a multi-threaded runtime. The signaling writer sends requests in channel arrival order, not in Python call order. If the earlier task reaches that channel last, the media server applies the older value. A repeat call requesting the current local value is a no-op.
Example: An agent calls set_enabled(False) and then set_enabled(True) while both updates are still being sent. If the resume task enqueues first, the server processes resume and then pause. The local track stays enabled, but incoming media stays paused.
Recommended fix: Serialize settings updates per publication in the native SDK, or coalesce pending updates into a single ordered sender that always transmits the newest desired settings last. Test two sequential API calls with the first send deliberately delayed.
Was this helpful? React with 👍 or 👎 to provide feedback.
| req.enable_remote_track_publication.track_publication_handle = self._ffi_handle.handle | ||
| req.enable_remote_track_publication.enabled = enabled | ||
| FfiClient.instance.request(req) |
There was a problem hiding this comment.
🟡 Media toggles overwrite simulcast settings
On a simulcast track, set_enabled(True) overwrites the layer selected by set_video_quality with Low. Changing quality while paused also tells the media server to resume forwarding.
Learn more
Both operations send the same subscriber-settings message to the media server. The native enable callback fills in disabled but leaves quality at its protocol default, Low. The native quality callback fills in quality but leaves disabled at false. LiveKit Server's mergeSubscriberSettings preserves omitted FEC settings, not quality or disabled, and SubscribedTrack.applySettings uses the resulting settings for forwarding and layer selection.
Example: A subscriber selects High for a simulcast camera, pauses it, then resumes it. The resume request carries Low, so the server switches to the lowest layer. If the subscriber selects High during the pause instead, the settings request clears the server pause even though the local track stays disabled.
Recommended fix: Keep a single set of desired subscriber settings in the Rust SDK and send the full set on either update, preserving both the requested layer and whether forwarding is paused. Cover each call order with a server-backed simulcast test.
Was this helpful? React with 👍 or 👎 to provide feedback.
Closes #976.
Motivation
Real-time voice and language-learning agents need to pause incoming microphone media between speaking attempts while keeping the subscription intact. Unsubscribing and resubscribing can require negotiation and stream recreation, risking loss of initial speech. Discarding frames in an agent input gate does not stop downstream media transfer. Publisher mute is a separate user-controlled operation.
Changes
RemoteTrackPublication.set_enabled(enabled: bool)to expose the existingEnableRemoteTrackPublicationRequestFFI operation.The existing generated Python protocol and pinned Rust FFI handler already implement the request; no native SDK or protobuf regeneration is needed.
Validation
This API is intended for frequent subscriber-side toggles, not remote microphone unmute. It does not guarantee zero latency or immediate drainage of in-flight media.