From f71e4830806008f732d1876bbfb0a4075d41e123 Mon Sep 17 00:00:00 2001 From: Timo K Date: Thu, 15 Jan 2026 18:13:34 +0100 Subject: [PATCH] logging updates --- src/livekit/MatrixAudioRenderer.tsx | 1 + src/settings/DeveloperSettingsTab.tsx | 1 + .../CallViewModel/localMember/Publisher.ts | 14 +++++++++-- .../CallViewModel/remoteMembers/Connection.ts | 24 ++++++++++++++++--- .../remoteMembers/ConnectionManager.ts | 4 ---- 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/livekit/MatrixAudioRenderer.tsx b/src/livekit/MatrixAudioRenderer.tsx index 5a4b2257..10579c1b 100644 --- a/src/livekit/MatrixAudioRenderer.tsx +++ b/src/livekit/MatrixAudioRenderer.tsx @@ -78,6 +78,7 @@ export function LivekitRoomAudioRenderer({ .filter((ref) => { const isValid = validIdentities.includes(ref.participant.identity); if (!isValid) { + // TODO make sure to also skip the warn logging for the local identity // Log that there is an invalid identity, that means that someone is publishing audio that is not expected to be in the call. prefixedLogger.warn( `Audio track ${ref.participant.identity} from ${url} has no matching matrix call member`, diff --git a/src/settings/DeveloperSettingsTab.tsx b/src/settings/DeveloperSettingsTab.tsx index a94dca26..91a2e241 100644 --- a/src/settings/DeveloperSettingsTab.tsx +++ b/src/settings/DeveloperSettingsTab.tsx @@ -316,6 +316,7 @@ export const DeveloperSettingsTab: FC = ({ })}

LivekitAlias: {livekitRoom.livekitAlias}

+

connectionState (wont hot reload): {livekitRoom.room.state}

{livekitRoom.isLocal &&

ws-url: {localSfuUrl?.href}

}

{t("developer_mode.livekit_server_info")}( diff --git a/src/state/CallViewModel/localMember/Publisher.ts b/src/state/CallViewModel/localMember/Publisher.ts index 27c53726..06f40bde 100644 --- a/src/state/CallViewModel/localMember/Publisher.ts +++ b/src/state/CallViewModel/localMember/Publisher.ts @@ -79,10 +79,20 @@ export class Publisher { this.workaroundRestartAudioInputTrackChrome(devices, scope); this.scope.onEnd(() => { - this.logger.info("Scope ended -> stop publishing all tracks"); - void this.stopPublishing(); muteStates.audio.unsetHandler(); muteStates.video.unsetHandler(); + this.logger.info( + "Scope ended -> unset handler + stop publishing all tracks", + ); + + const stopAllMedia = async () => { + logger.info("onEnd: start stopping all media"); + await this.stopPublishing(); + logger.info("onEnd: stopped publishing"); + await this.stopTracks(); + logger.info("onEnd: stopped tracks"); + }; + void stopAllMedia(); }); this.connection.livekitRoom.localParticipant.on( diff --git a/src/state/CallViewModel/remoteMembers/Connection.ts b/src/state/CallViewModel/remoteMembers/Connection.ts index 028b28f6..4db96d9b 100644 --- a/src/state/CallViewModel/remoteMembers/Connection.ts +++ b/src/state/CallViewModel/remoteMembers/Connection.ts @@ -155,6 +155,16 @@ export class Connection { const { url, jwt, livekitAlias } = this.existingSFUConfig ?? (await this.getSFUConfigForRemoteConnection()); + this.logger.debug( + "Starting Connection to: ", + this.transport.livekit_service_url, + "jwt: ", + jwt, + "wss: ", + url, + "livekitAlias: ", + livekitAlias, + ); this._livekitAlias = livekitAlias; // If we were stopped while fetching the config, don't proceed to connect if (this.stopped) return; @@ -171,8 +181,11 @@ export class Connection { }); try { + this.logger.info(`livekitRoom.connect ${url}`); await this.livekitRoom.connect(url, jwt); + this.logger.info(`livekitRoom.connect SUCCESS ${url}`); } catch (e) { + this.logger.info(`livekitRoom.connect FAILED ${url}`, e); // LiveKit uses 503 to indicate that the server has hit its track limits. // https://github.com/livekit/livekit/blob/fcb05e97c5a31812ecf0ca6f7efa57c485cea9fb/pkg/service/rtcservice.go#L171 // It also errors with a status code of 200 (yes, really) for room @@ -233,12 +246,15 @@ export class Connection { */ public async stop(): Promise { this.logger.debug( - `Stopping connection to ${this.transport.livekit_service_url}`, + `stop: disconnecing from lk room ${this.transport.livekit_service_url}`, ); if (this.stopped) return; await this.livekitRoom.disconnect(); this._state$.next(ConnectionState.Stopped); this.stopped = true; + this.logger.debug( + `stop: DONE disconnecing from lk room ${this.transport.livekit_service_url}`, + ); } private readonly client: OpenIDClientParts; @@ -255,9 +271,11 @@ export class Connection { public constructor(opts: ConnectionOpts, logger: Logger) { this.ownMembershipIdentity = opts.ownMembershipIdentity; this.existingSFUConfig = opts.existingSFUConfig; - this.logger = logger.getChild("[Connection]"); + this.logger = logger.getChild( + "[Connection " + opts.transport.livekit_service_url + "]", + ); this.logger.info( - `Creating new connection to ${opts.transport.livekit_service_url} ${opts.transport.livekit_alias}`, + `constructor: ${opts.transport.livekit_service_url} alias: ${opts.transport.livekit_alias} withSfuConfig?: ${sfuConfig})`, ); const { transport, client, scope } = opts; diff --git a/src/state/CallViewModel/remoteMembers/ConnectionManager.ts b/src/state/CallViewModel/remoteMembers/ConnectionManager.ts index 4295c5f2..8bc008ea 100644 --- a/src/state/CallViewModel/remoteMembers/ConnectionManager.ts +++ b/src/state/CallViewModel/remoteMembers/ConnectionManager.ts @@ -189,10 +189,6 @@ export function createConnectionManager$({ } }, (scope, _data$, serviceUrl, alias, sfuConfig) => { - logger.debug( - `Creating connection to ${serviceUrl} (${alias}, withSfuConfig (local connection?): ${JSON.stringify(sfuConfig) ?? "no config->remote connection"})`, - ); - const connection = connectionFactory.createConnection( scope, {