Skip to content

Conversation

@toger5
Copy link
Contributor

@toger5 toger5 commented Nov 25, 2025

This PR refactors LocalMembership.ts to use reconcile for cleaning up tracks. It also enables track and publisher creation to be reactive to the local transport and the connection.

Copy link
Member

@BillCarsonFr BillCarsonFr left a comment

Choose a reason for hiding this comment

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

Great work thanks. The quality gate is 🤩
We did some live pair session on it already.
I'd like just that we add more debug logs on the LocalMembership/publisher. things about the lifecycle:
start tracks requested
Creating traks
Request disconnect

Looks like we only have logging on error. I'd like that we add a lot more logs, and eventually revert later if too verbose or impacting perfs

Connecting = "connecting",
Connected = "connected",
Error = "error",
/** Not even a transport is available to the LocalMembership */
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe we could name this RTCBackendState? rather than LivekitState? Because it could be confused to the actual Livekit Room connection state?
It would also better match the name we use in the EC readme main schema?

matrixRTCSession,
}: Props): {
requestConnect: () => LocalMemberConnectionState;
requestConnect: () => void;
Copy link
Member

Choose a reason for hiding this comment

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

nit: Maybe add some quick comments on what all these does?

: of(false),
),
localConnectionState$.pipe(
map((state) => (state ? state.state === "ConnectedToLkRoom" : false)),
Copy link
Member

Choose a reason for hiding this comment

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

When state.state === "ConnectedToLkRoom" should we then look at the inner livekitConnectionState? to look for Disconnected / SignalReconnecting?

  | {
      state: "ConnectedToLkRoom";
      livekitConnectionState$: Observable<LivekitConenctionState>;
    }

);
const publishing$ = scope.behavior(
publisher$.pipe(
switchMap((p) => (p?.publishing$ ? p.publishing$ : constant(false))),
Copy link
Member

Choose a reason for hiding this comment

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

nit: I am not a fan of the condensed/ternary notation. Can I at least get a comment of what is doing and why?


// While this loop runs it will process the latest from `value$` until it caught up with the updates.
// It might skip updates from `value$` and only process the newest value after callback has resolved.
const reconcileLoop = async (): Promise<void> => {
Copy link
Member

Choose a reason for hiding this comment

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

we might want to merge develop in to have the reconcile test #3597

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.

3 participants