From e12be12e1827ba604d7684abf4b84d9a11e28e26 Mon Sep 17 00:00:00 2001 From: Chandran Date: Fri, 19 Jun 2026 22:27:58 +0200 Subject: [PATCH] fix(camera): recover browser preview after permission is granted The camera preview video element made a single getUserMedia attempt. On first use it can fail before the page has been granted camera permission (the grant is driven separately by useAvailableCameras' probe) or while the device is briefly held right after that probe releases it. Because the deviceId does not change once permission lands, the hook stayed stuck on the error state until a full page reload -- visible on the calibration and recording camera previews as a failed preview / "No browser match". Retry the stream a few times with backoff, and re-attempt when the media device list changes (granting permission fires a devicechange event) but only while in the error state, so a healthy stream is never torn down. The preview now recovers on its own without a reload. --- frontend/src/hooks/useCameraStream.ts | 59 ++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/frontend/src/hooks/useCameraStream.ts b/frontend/src/hooks/useCameraStream.ts index f770fd2..1f44cf1 100644 --- a/frontend/src/hooks/useCameraStream.ts +++ b/frontend/src/hooks/useCameraStream.ts @@ -4,10 +4,46 @@ import { useEffect, useRef, useState } from "react"; * Attach a live browser camera stream to a `