wip try to enhance error handling

This commit is contained in:
lebaudantoine
2026-09-02 20:48:16 +02:00
parent c783fefa57
commit 35cb114160
2 changed files with 51 additions and 12 deletions
@@ -201,10 +201,23 @@ export const EffectsConfiguration = ({
* *
* We arrive in this condition when we enter the room with the camera already off. * We arrive in this condition when we enter the room with the camera already off.
*/ */
const newProcessorTmp = BackgroundProcessorFactory.getProcessor(config)! try {
await toggle(true, { const newProcessorTmp =
processor: newProcessorTmp, BackgroundProcessorFactory.getProcessor(config)!
}) await toggle(true, {
processor: newProcessorTmp,
})
} catch (error) {
reportError('effects_processor_failure', error, {
context: 'Error applying effect while enabling camera:',
})
saveProcessorConfig(undefined)
try {
await toggle(true)
} catch {
// Camera errors are handled by the toggle's own error path.
}
}
setTimeout(() => setProcessorPending(false)) setTimeout(() => setProcessorPending(false))
return return
} }
@@ -246,6 +259,14 @@ export const EffectsConfiguration = ({
reportError('effects_processor_failure', error, { reportError('effects_processor_failure', error, {
context: 'Error applying effect:', context: 'Error applying effect:',
}) })
try {
if (videoTrack.getProcessor()) {
await videoTrack.stopProcessor()
}
} catch {
// Best effort: the processor may already be broken.
}
saveProcessorConfig(undefined)
} finally { } finally {
// Without setTimeout the DOM is not refreshing when updating the options. // Without setTimeout the DOM is not refreshing when updating the options.
setTimeout(() => setProcessorPending(false)) setTimeout(() => setProcessorPending(false))
@@ -22,10 +22,12 @@ import { VOICE_AUDIO_CONSTRAINTS } from '../utils/constants'
import { import {
saveAudioInputDeviceId, saveAudioInputDeviceId,
saveAudioInputEnabled, saveAudioInputEnabled,
saveProcessorConfig,
saveVideoInputDeviceId, saveVideoInputDeviceId,
saveVideoInputEnabled, saveVideoInputEnabled,
userChoicesStore, userChoicesStore,
} from '@/stores/userChoices' } from '@/stores/userChoices'
import { reportError } from '@/features/analytics/telemetry'
import { useSyncTrackDeviceId } from './useSyncTrackDeviceId' import { useSyncTrackDeviceId } from './useSyncTrackDeviceId'
// Module-level: effect dependencies, must be referentially stable. // Module-level: effect dependencies, must be referentially stable.
@@ -221,15 +223,31 @@ export function useJoinTracks(): {
[audioDeviceId] [audioDeviceId]
) )
const createVideo = useCallback( const createVideo = useCallback(async () => {
() => const processor =
createLocalVideoTrack({ BackgroundProcessorFactory.fromProcessorConfig(processorConfig)
if (!processor) {
return createLocalVideoTrack({ deviceId: videoDeviceId })
}
try {
return await createLocalVideoTrack({
deviceId: videoDeviceId, deviceId: videoDeviceId,
processor: processor,
BackgroundProcessorFactory.fromProcessorConfig(processorConfig), })
}), } catch (error) {
[videoDeviceId, processorConfig] // A camera problem (permission, device missing/busy) is not the
) // effect's fault: let the normal media error handling deal with it
// without touching the user's saved effect.
if (getMediaDeviceFailure(error as Error)) {
throw error
}
reportError('effects_processor_failure', error, {
context: 'Restoring saved effect failed, retrying without it',
})
saveProcessorConfig(undefined)
return createLocalVideoTrack({ deviceId: videoDeviceId })
}
}, [videoDeviceId, processorConfig])
const audioTrack = useLocalTrack({ const audioTrack = useLocalTrack({
ready: audioReady, ready: audioReady,