Select which package(s) are affected
@livekit/components-react
Describe the bug
When videoSimulcastLayers or screenShareSimulcastLayers are passed in options to <LiveKitRoom /> (or useLiveKitRoom), publishing a video track can trigger a full room teardown and reconnect.
The cause is a combination of two things:
useLiveKitRoom recreates the Room instance whenever JSON.stringify(options) changes between renders.
- The livekit-client SDK's internal
sortPresets function sorts simulcast layer arrays in place when a track is published, mutating the original options object.
After the first publish, the simulcast layers array inside options has been reordered. On the next render, JSON.stringify(options) produces a different string, the effect fires, a new Room is created, and the old one is disconnected.
Reproduction
Pass videoSimulcastLayers in an order that isn't already sorted by maxBitrate ascending, then publish a camera track. You'll see the room disconnect and reconnect.
Logs
System Info
System:
OS: macOS 26.5.1
CPU: (10) arm64 Apple M4
Memory: 116.52 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.16.0 - /Users/jk/.nvm/versions/node/v24.16.0/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 11.13.0 - /Users/jk/.nvm/versions/node/v24.16.0/bin/npm
pnpm: 10.28.1 - /opt/homebrew/bin/pnpm
Browsers:
Chrome: 149.0.7827.115
Firefox: 152.0
Safari: 26.5
npmPackages:
@livekit/components-core: ^0.12.13 => 0.12.13
@livekit/components-react: ^2.9.21 => 2.9.21
@livekit/components-styles: ^1.2.0 => 1.2.0
livekit-client: ^2.19.1 => 2.19.1
Severity
annoyance
Additional Information
No response
Select which package(s) are affected
@livekit/components-react
Describe the bug
When
videoSimulcastLayersorscreenShareSimulcastLayersare passed in options to<LiveKitRoom />(oruseLiveKitRoom), publishing a video track can trigger a full room teardown and reconnect.The cause is a combination of two things:
useLiveKitRoomrecreates theRoominstance wheneverJSON.stringify(options)changes between renders.sortPresetsfunction sorts simulcast layer arrays in place when a track is published, mutating the originaloptionsobject.After the first publish, the simulcast layers array inside
optionshas been reordered. On the next render,JSON.stringify(options)produces a different string, the effect fires, a newRoomis created, and the old one is disconnected.Reproduction
Pass videoSimulcastLayers in an order that isn't already sorted by maxBitrate ascending, then publish a camera track. You'll see the room disconnect and reconnect.
Logs
System Info
System: OS: macOS 26.5.1 CPU: (10) arm64 Apple M4 Memory: 116.52 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 24.16.0 - /Users/jk/.nvm/versions/node/v24.16.0/bin/node Yarn: 1.22.22 - /opt/homebrew/bin/yarn npm: 11.13.0 - /Users/jk/.nvm/versions/node/v24.16.0/bin/npm pnpm: 10.28.1 - /opt/homebrew/bin/pnpm Browsers: Chrome: 149.0.7827.115 Firefox: 152.0 Safari: 26.5 npmPackages: @livekit/components-core: ^0.12.13 => 0.12.13 @livekit/components-react: ^2.9.21 => 2.9.21 @livekit/components-styles: ^1.2.0 => 1.2.0 livekit-client: ^2.19.1 => 2.19.1Severity
annoyance
Additional Information
No response