diff --git a/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift b/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift index 19e0f2a..9497c46 100644 --- a/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift +++ b/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift @@ -2668,13 +2668,17 @@ extension LiveRoomViewModel: AgoraRtcEngineDelegate { } func rtcEngine(_ engine: AgoraRtcEngineKit, didOfflineOfUid uid: UInt, reason: AgoraUserOfflineReason) { - DispatchQueue.main.async {[unowned self] in - if uid == UInt(self.liveRoomInfo!.creatorId) { + DispatchQueue.main.async { [weak self] in + guard let self else { return } + guard let creatorId = self.liveRoomInfo?.creatorId else { return } + + if uid == UInt(creatorId) { // 라이브 종료 - self.stopV2VTranslationIfJoined() + self.deInitAgoraEngine() self.liveRoomInfo = nil - self.errorMessage = "라이브가 종료되었습니다." - self.isShowErrorPopup = true + AppState.shared.errorMessage = "라이브가 종료되었습니다." + AppState.shared.isShowErrorPopup = true + AppState.shared.roomId = 0 } else { // get room info self.getRoomInfo() diff --git a/docs/20260313_라이브종료참여자블랙스크린수정.md b/docs/20260313_라이브종료참여자블랙스크린수정.md new file mode 100644 index 0000000..4dc06f9 --- /dev/null +++ b/docs/20260313_라이브종료참여자블랙스크린수정.md @@ -0,0 +1,30 @@ +# 20260313 라이브 종료 참여자 블랙 스크린 수정 + +## 구현 체크리스트 +- [x] LiveRoom V2 참여자 종료 흐름 관련 코드 위치 확인 +- [x] 방장 종료 이벤트 수신 시 참여자 퇴장 로직 원인 분석 +- [x] 블랙 스크린 재현 경로 차단하도록 최소 수정 +- [x] 수정 코드 정적 진단 및 빌드 검증 +- [x] 수동 검증 시나리오와 결과 기록 + +## 완료 기준 (Acceptance Criteria) +- [ ] QA: 참여자 상태에서 방장이 라이브 종료 시 `라이브가 종료되었습니다` 토스트가 노출된다. +- [ ] QA: 토스트 노출 이후 라이브 화면이 닫히고 앱에서 다른 화면 조작이 가능하다. +- [ ] QA: 방장 본인 종료 동작은 기존과 동일하게 정상 동작한다. + +## 검증 기록 +- [2026-03-13] 무엇: 참여자 상태에서 방장 종료 시 블랙 스크린이 남는 원인 분석 및 최소 수정 + - 왜: `didOfflineOfUid` 경로에서 `liveRoomInfo`만 nil 처리되어 `HomeView` 오버레이(`appState.isShowPlayer`)가 유지되는 상태였음 + - 어떻게: `SodaLive/Sources/Live/Room/LiveRoomViewModel.swift`의 호스트 오프라인 분기에서 `deInitAgoraEngine()` 호출 후 전역 토스트(`AppState.shared.errorMessage`, `AppState.shared.isShowErrorPopup`)를 노출하고 `AppState.shared.roomId = 0`으로 오버레이 종료 트리거를 추가. Oracle 검토 반영으로 `[weak self]` + `creatorId` 가드도 추가해 콜백 경합 시 강제 언래핑 크래시 가능성을 제거 +- [2026-03-13] 실행 명령 및 결과 + - `xcodebuild -workspace "SodaLive.xcworkspace" -scheme "SodaLive" -configuration Debug build` → `BUILD SUCCEEDED` + - `xcodebuild -workspace "SodaLive.xcworkspace" -scheme "SodaLive-dev" -configuration Debug build` → `BUILD SUCCEEDED` + - `xcodebuild -workspace "SodaLive.xcworkspace" -scheme "SodaLive" test` → `Scheme SodaLive is not currently configured for the test action.` + - `xcodebuild -workspace "SodaLive.xcworkspace" -scheme "SodaLive-dev" test` → `Scheme SodaLive-dev is not currently configured for the test action.` + - `lsp_diagnostics(LiveRoomViewModel.swift)` → 개발 환경 SourceKit 의존성 인덱싱 한계로 `No such module 'Moya'` 반환 (빌드는 성공) + - 코드 수정 후 재검증: `xcodebuild -workspace "SodaLive.xcworkspace" -scheme "SodaLive" -configuration Debug build && xcodebuild -workspace "SodaLive.xcworkspace" -scheme "SodaLive-dev" -configuration Debug build` → 두 스킴 모두 `BUILD SUCCEEDED` + - 코드 수정 후 재검증: `xcodebuild -workspace "SodaLive.xcworkspace" -scheme "SodaLive" test; xcodebuild -workspace "SodaLive.xcworkspace" -scheme "SodaLive-dev" test` → 두 스킴 모두 test action 미구성 에러 동일 +- [2026-03-13] 수동 검증 시나리오 + - 시나리오: 2개 클라이언트(방장/참여자) 동시 접속 후 방장이 종료 버튼 실행 + - 기대 결과: 참여자에게 `라이브가 종료되었습니다` 토스트 노출 후 라이브 오버레이 종료 + - 현재 결과: CLI 환경에서는 실시간 2클라이언트/계정 세션을 구성할 수 없어 실제 실행 검증은 로컬 앱 환경에서 추가 확인 필요