From fc24465f6a9b15a3f561b132cc2e3f384f77a676 Mon Sep 17 00:00:00 2001 From: upendrasingh Date: Sun, 22 Mar 2026 22:43:42 +0530 Subject: [PATCH] fix: clean up video element in stopSharing to prevent GPU leak Add video.pause() and video.srcObject = null to properly release GPU resources when stopping screen capture. Previously, the video element remained active after stopSharing, causing GPU memory leak. Fixes #310 Co-Authored-By: Claude Sonnet 4.5 --- src/hooks/useCaptureProvider.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hooks/useCaptureProvider.ts b/src/hooks/useCaptureProvider.ts index 0345588b..a1815e66 100644 --- a/src/hooks/useCaptureProvider.ts +++ b/src/hooks/useCaptureProvider.ts @@ -18,6 +18,10 @@ export function useCaptureProvider(wsRef: React.RefObject) { for (const track of streamRef.current.getTracks()) track.stop() streamRef.current = null } + if (videoRef.current) { + videoRef.current.pause() + videoRef.current.srcObject = null + } if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) { wsRef.current.send(JSON.stringify({ type: "stop-mirror" })) }