Repository navigation
fix(core): surface local-track device changes in activeDeviceObservable - #1481
ninglinLiu wants to merge 6 commits into
Conversation
setupDeviceSelector wrote the selected device id to activeDeviceSubject when a preview/local track was switched, but returned only the room's ActiveDeviceChanged observable. PreJoin and other preview callers never saw the new activeDeviceId, so the menu stayed on the old device and onSubmit kept the previous id. Merge the subject into the returned observable so local-track selections and room events both update activeDeviceId. Fixes livekit#1472
|
@ninglinLiu is attempting to deploy a commit to the LiveKit Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 995a463 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thanks for the PR. #1472 is still present on Background: #1056 (31a2b04) switched Requested changes:
🤖 Generated with Claude Code |
- Only merge activeDeviceSubject when localTrack is provided - Keep room path using only ActiveDeviceChanged to avoid double emissions - Add room-mode test verifying single emission per device switch - Add changeset for @livekit/components-core patch Addresses review feedback from @1egoman on PR livekit#1481 Co-authored-by: NingLin Liu <x07514475479@gmail.com>
Replace Function with an explicit listener type and satisfy prettier wrapping so the lint job passes after the preview-only merge fix.
|
Thanks @1egoman — addressed your three points:
Happy to adjust further if you'd like the room branch to stop writing to |
Now that local-track device changes reach `onActiveDeviceChange`, PreJoin reacted to each selection by recreating both preview tracks, and the remounted device menus re-applied `initialSelection` without `exact`, which could make the browser resolve back to the default device. - PreJoin: only recreate preview tracks when audio/video is enabled or disabled (or the video processor changes); read the latest device ids from a ref instead of passing them as options. - MediaDeviceSelect: apply `initialSelection` once per mount, and skip it when the track is already on that device. - useMediaDeviceSelect: seed `activeDeviceId` from the local track's current device when one is provided.
|
Did a bit of manual testing of this - I think there still was some work left to do here which I have committed to this branch. cc @lukasIO I would like you take a glance at this just to get another pair of eyes on this, given you are more familiar with this the prefabs code than I am. Issue descriptionI noticed that when rendering Working with a LLM, it looks like this was because fixing #1472 exposed another bug which was hidden due to PreJoin rebuilt both preview tracks on every time a new input device was selected. It passed What I did to fix itOn main, the switch at least worked and only the ui rendered highlight was stale. But this render loop situation is pretty bad, so I pushed up 995a463 to try to fix it:
DemoVideo showing current end state of this branch (recorded in chrome, but reproduced in firefox and safari): Screen.Recording.2026-11-03.at.11.30.24.AM.mov |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Description
setupDeviceSelectorwrote the selected device id toactiveDeviceSubjectwhen switching a preview/local track, but returned only the room'sActiveDeviceChangedobservable. Preview /PreJoincallers never saw the newactiveDeviceId, so the menu stayed on the old device andonSubmitkept the previous id.Merge the subject into the returned observable so local-track selections and room events both update
activeDeviceId.Related issues
Fixes #1472
Test plan
useMediaDeviceSelectpreview-mode unit test to assertactiveDeviceIdbecomesmic-2aftersetActiveMediaDevice('mic-2').onSubmitreceives that device id.This PR was prepared with AI assistance and reviewed/tested by the author.