livekit / python-sdks

LiveKit real-time and server SDKs for Python
https://docs.livekit.io
Apache License 2.0
72 stars 23 forks source link

On agent disconnect and reconnect, track_subscribed event reports track.muted as True even when muted #207

Open Tryptophan opened 3 weeks ago

Tryptophan commented 3 weeks ago

I've found a bug with agents where on disconnecting/reconnecting due to temporary network failures then subscribing to a participant track the track reports as not muted even when it is muted. To reproduce use the following code and steps.

Steps to reproduce:

  1. Join a room with a participant and publish an audio stream
  2. Mute the audio stream
  3. Manually disconnect internet connection (where agent is hosted) and reconnect when livekit agent logs disconnect
  4. On re-connection of the agent the following code will log even though the participant is muted
def on_track_subscribed(
        track: rtc.Track,
        pub: rtc.RemoteTrackPublication,
        remote_participant: rtc.participant.RemoteParticipant,
    ):
        if track.kind == rtc.TrackKind.KIND_AUDIO and not track.muted:
            logging.info("this should not log when participant is muted")

job.room.on("track_subscribed", on_track_subscribed)