Repro: no ParticipantConnected for participants already in room at connect#342
Closed
MaxHeimbrock wants to merge 1 commit into
Closed
Repro: no ParticipantConnected for participants already in room at connect#342MaxHeimbrock wants to merge 1 commit into
MaxHeimbrock wants to merge 1 commit into
Conversation
…oom at connect A remote participant that is already in the room when the local participant connects (e.g. an agent dispatched concurrently with the user's connect) is delivered in the connect snapshot instead of as a ParticipantConnected delta. No layer (Rust SDK, FFI, Unity) ever raises ParticipantConnected for snapshot participants, so apps driving their "participant joined" logic purely from that event never learn the participant exists — although it is present in Room.RemoteParticipants. The test connects an "agent" first, wires ParticipantConnected before the subscriber's Connect(), and uses a third late-joining participant as an in-order control: once the control's event has fired, any event for the agent would already have been dispatched, so the failing case is fast and deterministic. Currently fails (by design) with: ParticipantConnected never fired for 'snapshot-agent' ... It IS present in RemoteParticipants, so only the event is missing. Received: [snapshot-late-joiner] Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Deterministic reproduction of the field reports where a user joins a room concurrently with a remote participant (typically an agent being dispatched) and never realizes that participant is there — no
ParticipantConnected, and consequently no app-side track subscription/rendering.This PR is intentionally red. The test documents the current defect; the fix follows on this branch.
Mechanism
Whether a concurrently connecting participant lands in the local participant's connect snapshot or in the event stream is a server-side race (did it join before or after the local
JoinResponsewas generated). If it lands in the snapshot:join_response.other_participants(livekit/src/room/mod.rs:744— onlyhandle_participant_updateever dispatchesParticipantConnected, and only for participants not already known),ConnectCallbackpayload (build_initial_states) without events,RemoteParticipantsviaCreateRemoteParticipantWithTracks(Room.cs:596) without raising room-levelParticipantConnectedorTrackPublished.So even a handler wired before
Connect()never fires. The data is all there — only the events are missing. TheReadyForRoomEventhandshake is not at fault: the buffered-delta path it protects was verified watertight at all three layers.Test design
Three participants make the race deterministic and the failure fast (~3s, no timeout burn):
ParticipantConnectedbeforeConnect(), then connects.ParticipantConnected(regular delta path) serves as an in-order control: room events are delivered in order, so once the control event fired, the agent's event would already have been dispatched if it were ever coming.Current failure output:
Test plan
Scripts~/run_unity.sh test -m PlayMode -f SnapshotParticipantEventsTestsagainstlivekit-server --dev— fails on the repro assertion, control assertions passRoom.OnConnect)🤖 Generated with Claude Code