fix: resync voice state after LiveKit reconnect #289
Reference in New Issue
Block a user
Delete Branch "userAdityaa/flotilla:fix/287-livekit-voice-reconnect"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Reason
On a flaky network, LiveKit reconnects in the background and may log a track/participant mismatch in the console. More importantly for Flotilla, it does not emit join/leave events during reconnect, so our participant list and camera/screen-share UI could stay wrong after the connection came back.
Solution
On
RoomEvent.Reconnected, resync participant media and local session flags from the LiveKit room and refresh video tiles. If the call fully drops, show a Reconnect button that joins again with a fresh token.Related to: https://github.com/livekit/client-sdk-js/issues/1163
closes #287
@@ -94,1 +94,4 @@// LiveKit does not emit ParticipantConnected/Disconnected during reconnect.const resyncAfterReconnect = (room: LiveKitRoom) => {const next = new Map<string, {muted: boolean; cameraOn: boolean}>()Let's make this a named type instead of repeating the ad-hoc type in a bunch of places
@@ -95,0 +101,4 @@participantMediaState.set(next)const session = get(currentVoiceSession)if (session?.room !== room) returnThis will never match I would imagine, because it's checking identity equality, not value equality right?
@@ -240,0 +248,4 @@class="center tooltip tooltip-top btn btn-sm btn-square btn-success"onclick={onReconnect}><Icon icon={PhoneCallingRounded} size={4} /></Button>Is there any way to do this automatically? Adding a button to make the software work the way its supposed to is probably not a good pattern.
1f5a219734to7dfe24d264