fix(web): 권한 대기 중 언마운트 시 카메라·마이크 트랙 누수 제거 - #232
Open
i3months wants to merge 1 commit into
Open
Conversation
useWebcamPreview·useVoiceRecorder 가 getUserMedia 를 await 하는 동안 언마운트되면, 언마운트 cleanup 은 아직 null 인 streamRef 만 읽어 아무것도 정지하지 못한다. 그 뒤 권한이 뒤늦게 허용되면 스트림이 소유자 없는 훅에 할당되어 카메라 LED·마이크 표시등이 페이지 새로고침 전까지 켜진 채 남는다. 프롬프트가 열려 있는 창(수 초)이라 흔히 재현된다. - 두 훅에 requestId 세대값 도입. stop()/언마운트가 이를 올려 pending 을 무효화. - getUserMedia resolve 후 requestId 가 바뀌었으면 방금 열린 트랙을 즉시 정지. - 늦게 도착한 거부(catch)는 requestId 일치할 때만 denied 로 반영. - pending 중 언마운트 회귀 테스트 2건 추가 (수정 없으면 실패, 있으면 통과 확인). useVoiceRecorder 는 기존 cancel() 만 requestId 를 올려 언마운트 경로가 빠져 있었고, useWebcamPreview 는 세대값 자체가 없었다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
배경 — 코드 감사에서 발견
라이브 면접 미디어 훅(
features/interview/lib/media/) 정독 중 발견한 리소스 누수. 같은 버그 클래스가 두 훅에 있었다.useWebcamPreview·useVoiceRecorder는getUserMedia를await한다. 그 사이(권한 프롬프트가 열려 있는 수 초 동안) 컴포넌트가 언마운트되면:streamRef.current는 아직null이라 아무 트랙도 정지하지 못한다.getUserMedia가 resolve 되어 스트림이 이미 언마운트된 훅에 할당된다.useWebcamPreview의필수주석("카메라 LED 가 계속 켜지는 것 방지")이 정확히 이 레이스로 무력화되고 있었다.재현 동선
면접 중
카메라 켜기(또는 음성 답변) 클릭 → 브라우저 권한 프롬프트가 뜬 상태에서 면접 종료·이탈·연결 끊김 리다이렉트로InterviewStage언마운트 → 뒤늦게 권한 허용 → 장치 표시등 잔존.변경
requestId세대값 도입.stop()과 언마운트 cleanup 이 이를 올려 pending 인getUserMedia를 무효화한다.getUserMediaresolve 후requestId가 바뀌었으면 방금 열린 트랙을 즉시stop().catch)는requestId가 일치할 때만denied로 반영(무효화 후 상태 되돌림 방지).useVoiceRecorder는 기존에cancel()만requestId를 올려 언마운트 경로가 누락돼 있었고,useWebcamPreview는 세대값 자체가 없었다.테스트
🤖 Generated with Claude Code