client-sdk-js icon indicating copy to clipboard operation
client-sdk-js copied to clipboard

Restarted audio tracks always get "default" deviceId constraint

Open v-flashpoint opened this issue 5 months ago • 1 comments

Describe the bug

What I'm expecting

When creating an audio track using createLocalTracks(), the user is given a permissions prompt through the browser, and track._constraints.deviceId is updated to be whatever they chose.

However, if the user then revokes microphone permission, although the user is prompted to choose another microphone, track._constraints.deviceId always gets set to default. This means that any future attempts to mute/unmute using this mic will cause the track to be reacquired, as laid out in LocalAudioTrack.ts, as the deviceIds no longer match, causing a brief flicker in the stream.

I was expecting that when the user chose their preferred microphone from the dialogue, the track._constraints.deviceId would be updated with the option they chose, as it is when they first create the track using createLocalTracks.

What happens instead

See above

Reproduction

  • Create audio and video tracks using createLocalTracks() (it may also be important to choose a non-default mic)
  • Revoke permission to your microphone
  • Choose another mic (in my case, I chose the same one again)
  • Mute and unmute
  • LiveKit will attempt to reacquire the track due to a mismatch in the deviceId

Logs


System Info

Windows 10, Firefox 140.0.4, latest LiveKit JS SDK

Severity

annoyance

Additional Information

No response

v-flashpoint avatar Jul 23 '25 14:07 v-flashpoint

is this a Firefox specific issue?

It sounds like an edge case that a user would allow permissions to a certain device and then revoke it. I agree the SDK should handle this gracefully, just want to understand when this actually occurs in actual usage scenarios.

lukasIO avatar Sep 22 '25 09:09 lukasIO