livekit / client-sdk-flutter

Flutter Client SDK for LiveKit

Home Page:https://docs.livekit.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug] Commit f08556e introduces invalid LocalParticipant TrackMutedEvent/TrackUnmutedEvent behavior

kNoAPP opened this issue · comments

Describe the bug
After f08556e, the TrackMutedEvent and TrackUnmutedEvent are called BEFORE the underlying Track data structure is updated to correct values. Specifically in this commit, the changes to lib/src/publication/track_publication.dart are problematic.

Say you are watching a local participant who has their mic unmuted. They click their mute button. We use this code to check the mic state...
Screenshot 2023-12-06 223516

Prior to f08556e, when a track was muted (in this example, a microphone going from unmuted -> muted state), the debugger would show the following:
Screenshot 2023-12-06 223454

From f08556e onwards, the debugger shows the OLD state-- which is no longer valid for the local participant. Its essentially a TrackMutedEvent that doesn't actually contain a muted == true in the referenced track:
Screenshot 2023-12-06 223718

To Reproduce
Listen to the TrackMutedEvent or TrackUnmutedEvent and observe the participant's track. Toggle the mute state of the track. You can use the above simplistic code as an example.

Expected behavior
Restore the behavior prior to f08556e. As a workaround, referencing event.participant.audioTracks.first.track!.muted maintains the old behavior.

Platform information

  • Flutter version:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.16.0, on Microsoft Windows [Version 10.0.22621.2715], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.29)
[√] Android Studio (version 2022.3)
[√] VS Code (version 1.84.2)
[√] Connected device (3 available)
[√] Network resources
  • Plugin version: ref: f08556e330e1070fb993da15f7c0e70d3e2b9684
  • Flutter target OS: Tested on Web/Chrome
  • Flutter target OS version: Windows 11/Chrome 119

Thank you @cloudwebrtc 😊