fix: reset hwOverdrive in all voice cleanup paths

Add hwOverdrive: false to resetSession(), leaveVoice(), and
handleForceDisconnect() store resets. Add deactivateHwOverdrive()
to disconnect callback and cleanup effect in useLiveKit.
Ensures "resets when stream ends" contract holds for edge cases
like server shutdown, identity collision, and logout.
This commit is contained in:
Jannis Braun
2026-03-24 04:00:37 +01:00
parent 66a0793297
commit 46c3838193
2 changed files with 6 additions and 1 deletions
+3 -1
View File
@@ -30,6 +30,7 @@ import {
resolveNativeOverdrive,
} from '../utils/screenShare';
import { getMediaStreamTrack } from '../utils/livekitInternals';
import { deactivate as deactivateHwOverdrive } from '../utils/hwOverdrive';
let _activeRoom: Room | null = null;
let _publishedScreenShareCodec: 'vp9' | 'h264' | null = null;
@@ -560,6 +561,7 @@ export function useLiveKit() {
const disconnect = useCallback(async () => {
_connectGeneration++;
SpeakingDetector.getInstance().clear();
deactivateHwOverdrive();
connectedChannelRef.current = null;
setConnectedChannelId(null);
if (roomRef.current) {
@@ -650,7 +652,7 @@ export function useLiveKit() {
}, [room, screenShareConfig, isScreenSharing, isCameraOn, hwOverdrive]);
useEffect(() => {
return () => { _connectGeneration++; SpeakingDetector.getInstance().clear(); if (roomRef.current) { destroyRoom(roomRef.current); roomRef.current = null; _activeRoom = null; } };
return () => { _connectGeneration++; SpeakingDetector.getInstance().clear(); deactivateHwOverdrive(); if (roomRef.current) { destroyRoom(roomRef.current); roomRef.current = null; _activeRoom = null; } };
}, []);
+3
View File
@@ -401,6 +401,7 @@ export const useVoiceStore = create<VoiceState>()(
resetSession: () => set({
// Connection state
hwOverdrive: false,
voiceUsers: new Map(),
voiceUserStates: new Map(),
currentVoiceChannelId: null,
@@ -459,6 +460,7 @@ export const useVoiceStore = create<VoiceState>()(
return {
currentVoiceChannelId: null,
hwOverdrive: false,
isCameraOn: false,
isScreenSharing: false,
participants: [],
@@ -493,6 +495,7 @@ export const useVoiceStore = create<VoiceState>()(
handleForceDisconnect: () => {
set({
currentVoiceChannelId: null,
hwOverdrive: false,
isCameraOn: false,
isScreenSharing: false,
participants: [],