Skip to content

fix: 뭉치 상세뷰 이름 변경뷰에서 뒤로가기 시 무한로딩 현상 픽스#64

Merged
giljihun merged 4 commits into
developfrom
fix/뭉치-상세뷰-이름-변경뷰에서-뒤로가기-시-무한로딩-현상-픽스
Feb 9, 2026

Hidden character warning

The head ref may contain hidden characters: "fix/\ubb49\uce58-\uc0c1\uc138\ubdf0-\uc774\ub984-\ubcc0\uacbd\ubdf0\uc5d0\uc11c-\ub4a4\ub85c\uac00\uae30-\uc2dc-\ubb34\ud55c\ub85c\ub529-\ud604\uc0c1-\ud53d\uc2a4"
Merged

fix: 뭉치 상세뷰 이름 변경뷰에서 뒤로가기 시 무한로딩 현상 픽스#64
giljihun merged 4 commits into
developfrom
fix/뭉치-상세뷰-이름-변경뷰에서-뒤로가기-시-무한로딩-현상-픽스

Conversation

@jini-coding
Copy link
Copy Markdown
Member

@jini-coding jini-coding commented Feb 9, 2026

🎯 PR 내용

⚠️ 문제 상황

BundleDetailView에서 BundleEditView 또는 BundleNameEditView로 진입 후 백버튼으로 돌아올 때 무한 로딩에 걸리는 현상 발생
BundleNameEditView의 경우, 백버튼을 눌렀을 때와 수정 완료 버튼을 눌렀을 때 두 케이스 모두 무한로딩 발생함

재현 방법:
BundleDetailView → BundleNameEditView → 백버튼or완료버튼 → 무한 로딩 ⭕️
BundleDetailView → BundleEditView → 백버튼 → BundleNameEditView → 백버튼 → 무한 로딩 ❌

🔍 원인 분석

1. ID 형식 불일치 문제

  • 편집 화면에서 돌아올 때 설정하는 returnIds와 DetailView에서 관리하는 lastConfigIds의 형식이 불일치
// NameEditView가 설정한 returnIds
returnBackgroundId: "WhiteKeychy"
returnCarabinerId: "PawPink|38.33|151.61|334.6"  // 좌표 포함
returnKeyringsId: "0|https://...|AcrylicPhoto|..."  // 상세 정보

// DetailView의 lastConfigIds (기존)
lastBackgroundIdForDetail: "WhiteKeychy"
lastCarabinerIdForDetail: "PawPink"  // 좌표 없음
lastKeyringsIdForDetail: "B7Bm2fNNkkUuLoYz3qyj|c42R5vHOiTA1snkWAPEO|..."  // Firebase ID만

2. ID 업데이트 타이밍 문제

  • MultiKeyringSceneView.onAllKeyringsReady에서 updateLastConfigIds() 호출
  • loadBundleData()에서도 lastConfigIds 업데이트 시도
  • 결과: 두 곳에서 서로 다른 형식으로 ID를 설정하여 충돌 발생

3. EditView 백버튼의 누락

  • EditView의 완료 버튼: returnIds 설정 → 정상 작동 ✅
  • EditView의 백버튼: returnIds 미설정 → 불일치 발생 → 무한 로딩 ❌

4. EditView에서 백버튼으로 돌아올 때 Scene 재생성 문제

  • keyringDataList는 업데이트됨
  • Scene의 .id()는 동일 → SwiftUI가 Scene을 재생성하지 않음
  • onAllKeyringsReady 콜백이 호출되지 않음
  • isSceneReady가 false로 유지 → 무한 로딩

🛠️ 해결 방법

1. ID 생성 로직 통일
모든 화면에서 makeBackgroundId(), makeCarabinerId(), makeKeyringsId() 사용:

// 편집 화면들 (EditView, NameEditView)
let bgId = bundleVM.makeBackgroundId(background)
let cbId = bundleVM.makeCarabinerId(carabiner)
let krId = bundleVM.makeKeyringsId(keyringDataList)

bundleVM.returnBackgroundId = bgId
bundleVM.returnCarabinerId = cbId
bundleVM.returnKeyringsId = krId

2. lastConfigIds 업데이트 단일화
onAllKeyringsReady에서의 updateLastConfigIds() 호출을 제거하고, loadBundleData()에서만 업데이트

3. EditView 백버튼 처리

BackToolbarButton {
    // lastConfigIds 초기화 → 무조건 리로드
    bundleVM.lastBackgroundIdForDetail = ""
    bundleVM.lastCarabinerIdForDetail = ""
    bundleVM.lastKeyringsIdForDetail = ""
    
    isNavigatingAway = true
    router.pop()
}

4. Scene 강제 재생성
Scene을 생성할 때 id에 따라 생성하므로,sceneReloadTrigger를 추가하여 loadBundleData() 완료 시 Scene이 항상 재생성되도록 보장

@State private var sceneReloadTrigger = UUID()

// Scene ID에 포함
.id("scene_\(background.id ?? "")_\(carabiner.id ?? "")_\(...)_\(sceneReloadTrigger.uuidString)")

// loadBundleData()에서 업데이트
sceneReloadTrigger = UUID()

📱 스크린샷 (UI 변경 시)

뭉치 이름 변경

ScreenRecording_02-09-2026.16-1.mov

뭉치 수정

ScreenRecording_02-09-2026.17-1.mov

🔗 관련 이슈

#23

✅ 체크리스트

  • 빌드 성공
  • 테스트 완료
  • Self-review 완료

Copy link
Copy Markdown
Member

@giljihun giljihun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeBackgroundId/makeCarabinerId/makeKeyringsId로
ID 생성 통일한 거 좋네여. 형식 불일치 문제 깔끔하게 해결 굿

.sorted()
.joined(separator: "|")
}
.id("scene_\(background.id ?? "")_\(carabiner.id ?? "")_\(keyringDataList.map { "\($0.index)_\($0.bodyImageURL.hashValue)" }.joined(separator: "_"))_\(sceneReloadTrigger.uuidString)")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sceneReloadTrigger 패턴 좋네요! 깔끔한 SwiftUI 강제 재생성 유도인듯요

++ ID 생성 로직이 좀 길잖아요? 제가 computed property로 한 번 가져왔습니다아

  private var sceneId: String {
      let bgId = background.id ?? ""
      let cbId = carabiner.id ?? ""
      let krIds = keyringDataList
          .map { "\($0.index)_\($0.bodyImageURL.hashValue)" }
          .joined(separator: "_")
      return "scene_\(bgId)_\(cbId)_\(krIds)_\(sceneReloadTrigger.uuidString)"
  }

.id(sceneId) 이렇게만 적는건 어떨까요~~

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아주 좋은 생각. 바로 반영해둘게요!

@giljihun giljihun merged commit 2c1d4ec into develop Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bugfix: [뭉치 상세뷰] 이름 변경뷰에서 뒤로가기 시 무한로딩 현상 픽스

2 participants