fix: auto-disable AEC during screen share to prevent Chrome voice ducking

Chrome's AEC uses getDisplayMedia audio as a reference signal and
aggressively ducks the microphone even when headphones are used.
This adds a screenShareActive flag to AudioManager that forces
echoCancellation off during screen share, plus Chromium-specific
goog* constraints as belt-and-suspenders.
This commit is contained in:
Jannis Braun
2026-02-20 15:22:20 +01:00
parent 25f72aef3b
commit 708bdf5468
7 changed files with 56 additions and 6 deletions
@@ -4,6 +4,7 @@ import { useServerStore } from '../../stores/serverStore';
import { useAuthStore } from '../../stores/authStore';
import { getActiveRoom } from '../../hooks/useLiveKit';
import { wsSend } from '../../hooks/useWebSocket';
import { AudioManager } from '../../audio/AudioManager';
import { VideoPresets, VideoPreset } from 'livekit-client';
const QUALITY_MAP: Record<string, any> = {
@@ -94,9 +95,11 @@ export function DmCallView() {
if (!room) return;
try {
if (!isScreenSharing) {
AudioManager.getInstance().setScreenShareActive(true);
await room.localParticipant.setScreenShareEnabled(true, { audio: true });
} else {
await room.localParticipant.setScreenShareEnabled(false);
AudioManager.getInstance().setScreenShareActive(false);
}
toggleScreenShare();
} catch (err) {
@@ -2,6 +2,7 @@ import React, { useRef, useEffect, useState, useCallback } from 'react';
import { Avatar } from '../ui/Avatar';
import { useVoiceStore } from '../../stores/voiceStore';
import { getActiveRoom, setStreamSubscription } from '../../hooks/useLiveKit';
import { AudioManager } from '../../audio/AudioManager';
import { VideoQualityPopover } from './VideoQualityPopover';
import type { StreamTile as StreamTileType } from '../../hooks/useLiveKit';
@@ -107,6 +108,7 @@ export function StreamTile({ tile, large }: StreamTileProps) {
const room = getActiveRoom();
if (room) {
await room.localParticipant.setScreenShareEnabled(false);
AudioManager.getInstance().setScreenShareActive(false);
useVoiceStore.getState().toggleScreenShare();
}
}, []);
@@ -3,6 +3,7 @@ import { useVoiceStore } from '../../stores/voiceStore';
import { useUIStore } from '../../stores/uiStore';
import { getActiveRoom } from '../../hooks/useLiveKit';
import { wsSend } from '../../hooks/useWebSocket';
import { AudioManager } from '../../audio/AudioManager';
import { VideoQualityPopover } from './VideoQualityPopover';
import { VideoPresets, VideoPreset } from 'livekit-client';
@@ -97,9 +98,11 @@ export function VoiceControlBar() {
if (!room) return;
try {
if (!isScreenSharing) {
AudioManager.getInstance().setScreenShareActive(true);
await room.localParticipant.setScreenShareEnabled(true, { audio: true });
} else {
await room.localParticipant.setScreenShareEnabled(false);
AudioManager.getInstance().setScreenShareActive(false);
}
toggleScreenShare();
} catch (err) {
@@ -3,6 +3,7 @@ import { useVoiceStore } from '../../stores/voiceStore';
import { useServerStore } from '../../stores/serverStore';
import { getActiveRoom } from '../../hooks/useLiveKit';
import { wsSend } from '../../hooks/useWebSocket';
import { AudioManager } from '../../audio/AudioManager';
import { VideoQualityPopover } from './VideoQualityPopover';
/**
@@ -43,9 +44,11 @@ export function VoiceControls() {
if (!room) return;
try {
if (!isScreenSharing) {
AudioManager.getInstance().setScreenShareActive(true);
await room.localParticipant.setScreenShareEnabled(true, { audio: true });
} else {
await room.localParticipant.setScreenShareEnabled(false);
AudioManager.getInstance().setScreenShareActive(false);
}
toggleScreenShare();
} catch (err) {