Skip to content

feat: 배경/카라비너 Lottie 애니메이션 지원#88

Merged
giljihun merged 21 commits intodevelopfrom
feature/-배경카라비너-로티-동작-로직-구현
Feb 12, 2026

Hidden character warning

The head ref may contain hidden characters: "feature/-\ubc30\uacbd\uce74\ub77c\ube44\ub108-\ub85c\ud2f0-\ub3d9\uc791-\ub85c\uc9c1-\uad6c\ud604"
Merged

feat: 배경/카라비너 Lottie 애니메이션 지원#88
giljihun merged 21 commits intodevelopfrom
feature/-배경카라비너-로티-동작-로직-구현

Conversation

@giljihun
Copy link
Member

🎯 PR 내용

로티를 이용한 카라비너/배경이 가능하게하는 기능을 구현했습니다.

기존에는 정적인 이미지를 기반으로 배경과 카라비너가 구성되었습니다.
그렇기에, 로티를 사용한 카라비너/배경을 동작하게 하려면 꽤나 다양한 곳에서의 구조 변경이 동반되었습니다.

로티 아이템을 파이어베이스 넣지 않아도 기존 로직이 동작하도록 호환성 100%를 갖게 구현했습니다.

1. 모델 변경

  • Background: backgroundLottie: String?, isLottie computed property 추가
  • Carabiner: carabinerLottie: [String]?, isLottie, backLottieURL, frontLottieURL 추가

2. 신규 파일

  • LottieItemManager.swift: Firebase Storage에서 Lottie JSON 다운로드/캐싱 매니저 (URL 기반 캐시 무효화)
  • LottieItemView.swift: UIViewRepresentable 기반 범용 Lottie 뷰 컴포넌트

캐시 무효화는 몇 PR전 진행했던, 이펙트 캐시 URL 비교해서 재다운하는 로직과 같다고 보심 됩니다!

3. 셀 렌더링

  • BackgroundCell, CarabinerCell: isLottie 분기 → LottieItemView 또는 기존 LazyImage
  • WorkshopItemCard, WorkshopItemDetailView: 공방 탭 Lottie 지원 추가

4. SpriteKit 씬 (핵심 of 핵심)

SpriteKit은 Lottie를 네이티브 지원하지 않아서, 이거 어케함 ㄱ- 이 시작이었는데,
기존 파티클 이펙트의 preRenderAllFrames() 패턴을 재활용했습니다.

원리: Lottie JSON → 모든 프레임을 UIImage로 렌더링 → SKTexture 배열 변환 → SpriteKit에서 재생

기존에 검증된 이펙트 렌더링 방식을 배경/카라비너에 확장 적용한 거라는 맥락이 최대한 드러나도록 했어요.

5. 비디오 생성

  • BundleVideoGenerator: backgroundLottieId, carabinerLottieId 파라미터 추가
  • 배경/카라비너 Lottie 프리렌더링 후 프레임별 텍스처 교체

6. Lottie ID 전달

  • 뭉치 생성/편집/디테일/완성뷰, 홈 대표뭉치 → MultiKeyringSceneView에 Lottie ID 전달
  • BundleViewModel+Fetch, WorkshopViewModel, CollectionViewModel → fetch 시 Lottie JSON 프리다운로드

전반적으로,
배경 카라비너를 사용하는 곳에선
Lottie야? 를 체크하도록 하고요.
Lottie면 이번 신규 로직들로 동작! 이렇게 보심됩니다.
그리고 파티클의 호출 방식과 유사하구요.

참고

  • 현재 보관함뭉치만들기에서 이름선정뷰 에서는 "정적인 이미지"가 필요해서
    기본 백그라운드가 나옵니다.

  • 로티 배경/카라비너가 나오면 모든 동작을 재테스트하고 영상 추출 등도 테스트 예정

📱 스크린샷 (UI 변경 시)

ScreenRecording_02-11-2026.22-30-36_1.MP4

🔗 관련 이슈

✅ 체크리스트

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

- Background: backgroundLottie(String?), isLottie computed property 추가
- Carabiner: carabinerLottie([String]?), isLottie/backLottieURL/frontLottieURL 추가
카라비너는 햄버거 타입도 있어서 배열.
- Optional 필드로 기존 Firestore 데이터 하위 호환 유지
- EffectManager와 동일한 다운로드/캐싱 패턴이지만, 배경/카라비너 도메인 전용
- LottieItemManager: Firebase Storage에서 Lottie JSON 다운로드/캐싱, URL 기반 캐시 무효화
- LottieItemView: UIViewRepresentable 기반 범용 Lottie 뷰 컴포넌트
- isLottie 체크 후 LottieItemView 또는 기존 LazyImage 분기
- MultiKeyringScene: Lottie→SKTexture 프리렌더링, SKAction.animate 반복 재생
- 비디오 모드에서는 프레임 인덱스 기반 수동 텍스처 교체
- MultiKeyringSceneView: carabinerLottieId 파라미터 전달
- generateVideo()에 backgroundLottieId, carabinerLottieId 파라미터 추가
- 배경 Lottie 프리렌더링 및 프레임별 텍스처 교체
- preRenderAllFrames() 접근제어를 internal로 변경하여 공용화
- BundleEditView/CreateView/DetailView: backgroundLottieId, carabinerLottieId 전달
- VideoGen 확장: generateVideo() 호출에 Lottie ID 전달
- BundleViewModel+Fetch: 배경/카라비너 fetch 시 Lottie JSON 프리다운로드
@giljihun giljihun self-assigned this Feb 11, 2026
@giljihun giljihun linked an issue Feb 11, 2026 that may be closed by this pull request
Copy link
Member

@jini-coding jini-coding left a comment

Choose a reason for hiding this comment

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

정말 대대적인 작업이었네요. 배경이랑 카라비너의 존재감이..ㄷㄷ
그래도 녹화 화면 보니까 예쁜 배경 넣으면 더 좋아보일 것 같아서 나중이 기대가 되는군요
고생하셨습니다...

실시간 뷰에서 Lottie 카라비너 SKTexture 프리렌더링을 제거하고
SwiftUI LottieItemView 오버레이로 대체하여 ~250MB 메모리 절감 및 즉시 로딩.
비디오/캡처 모드는 첫 프레임만 정적 렌더링하여 메모리 크래시 해결.
불필요한 데드코드(preRenderLottieFrames, TextureCacheEntry 등) 제거.
scene.update(0)으로 물리 타이밍 리셋 후 시뮬레이션 시간(frameIndex/fps)으로
일정한 delta 보장. 프레임 간 Task.sleep(0.0167)으로 물리 엔진 계산 시간 확보.
배경 Lottie도 첫 프레임만 정적 렌더링하여 메모리 사용량 대폭 감소.
빈 keyringDataList로 생성된 씬의 handleAllKeyringsReady Task가
실제 키링 씬보다 먼저 isSceneReady=true를 설정하는 레이스 컨디션 해결.
sceneReadyTask를 저장하고 새 로딩 시작 시 이전 Task를 취소하도록 변경.
- loadMainBundle의 모든 guard 실패 경로에 isSceneReady = true 복구
- 카라비너 resolve 실패 시 carabiners.first fallback 적용
- HomeView body에서 resolveCarabiner 재호출 대신 selectedCarabiner 직접 사용
- handleKeyringDataChange에서 sceneGeneration 증가 제거 (onChange 타이밍 불일치)
- handleKeyringDataChange에 키링 URL 시그니처 비교 추가 (같은 데이터 리로드 시 무한로딩 방지)
- onSetupComplete = nil 복원 (비로티 카라비너의 이전 씬 콜백 누출 차단)
- loadMainBundle 배치 업데이트 적용 (뭉치 전환 시 이전 키링 위치 혼입 방지)
- switchBundle에 Task 취소 로직 추가 (빠른 연속 전환 시 데이터 꼬임 방지)
아오 힘들어
@giljihun giljihun merged commit ab6ba27 into develop Feb 12, 2026
@giljihun giljihun deleted the feature/-배경카라비너-로티-동작-로직-구현 branch February 12, 2026 14:51
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.

Feature: [배경/카라비너] 로티 동작 로직 구현

2 participants