-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
Summary
The camera capture flow in js/utils/utils.js does expensive frame processing and may register duplicate listeners/intervals across repeated calls.
Code references
js/utils/utils.js:1106const data = canvas.toDataURL(image/png);js/utils/utils.js:1132cameraID = window.setInterval(draw, 100);js/utils/utils.js:1139video.addEventListener(canplay, ...);js/utils/utils.js:1151secondsetInterval(draw, 100)path insidecanplay
Why this matters
toDataURL(image/png)every 100ms is CPU-heavy and allocates large strings repeatedly.- Repeated
doUseCamera(...)calls can accumulatecanplaylisteners if not guarded/removed. - Duplicate interval start paths increase risk of extra background work.
Expected behavior
- Prevent duplicate
canplaylistener registration (store handler / use{ once: true }when valid). - Ensure only one capture interval is active per camera session.
- Consider lower-overhead capture alternatives (
toBlob, reduced cadence, or frame gating).
Suggested fix
Introduce camera-session lifecycle state in CameraManager:
- track and reuse/remove a single
canplayhandler, - track active capture interval id centrally,
- start/stop capture in one place with idempotent guards.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels