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.
💡 요약 및 이슈
썸네일 이미지를 불러오는 로직을 개선했습니다.
📃 작업내용
🧑🏻💻
URLString만 받아와서 셀 업데이트를 무조건 하게 하자!reload하는 방식을 채택해보았습니다.Channel의image속성도 지웠습니다.Cell이 이미지를 로드하는 방식을 다시 가져오기로 했습니다. 관련 PRURLString을 받아오면 각Cell이 이미지를 로드하는 방식이 합리적인 방법이라고 느껴졌습니다.// 각 셀에서 일어나는 일들 func configure(channel: Channel) { loadAsyncImage(with: channel.thumbnailImageURLString) self.titleLabel.text = channel.name self.descriptionLabel.text = channel.owner + (channel.description.isEmpty ? "" : " • \(channel.description)") } private func loadAsyncImage(with imageURLString: String) { guard let url = URL(string: imageURLString) else { return } URLSession.shared.dataTask(with: url) { [weak self] data, _, error in guard error == nil, let data else { return } DispatchQueue.main.async { self?.thumbnailView.configure(with: UIImage(data: data)) } }.resume() }👀 새로 생긴 고민 상황
applySnapshotUsingReloadData를 살펴보면 당연하게도without computing a diff or animating the changes라는 말이 있었습니다.reloadData()와 똑같이 작동하는 듯 보였습니다...🤔 잠깐만...
apply와 차이를 보면 성능에 큰 영향이 있을까?가장 궁금했던건 얼마나 성능 차이가 날까? 라는 궁금증이었습니다. 왜냐하면 applySnapshotUsingReloadData의 경우
Reset UI를 한다는 이야기가 있어 콜렉션뷰를 다시 그린다고 이해했기 때문에 리소스 차이가 얼마나 클까 하는 궁금증 이었습니다.방송을 2개 띄운 후 테스트를 진행해봤습니다.
CPU: 아무래도 image를 다시 받아오니까 CPU 사용량이 많을 수 밖에 없습니다. 51% → 58%
🥹
DiffableDataSource의 의미가 퇴색되었다.부드러운 애니메이션... 은 고사하고,
DiffableDataSource를 활용하여 이미 만들어진 셀을 재사용하면서 변경된 데이터만 업데이트하고 싶었는데... 이미지를 변경해야 하기 때문에 모든 셀을 다시 그려야하는 방식인applySnapshotUsingReloadData를 사용한 순간DiffableDataSource왜 쓰지? 라는 생각이 들었습니다.제가 원하는 방향은 이미지가 바뀔 때에만
apply snapshot을 하고 싶었습니다. 그렇게 된다면 셀을 업데이트 할때 바뀐 썸네일만 다시 그리니까 이미지를 다시 그리는 리소스도 줄어들 것이라고 생각했습니다.Building High-Performance Lists and Collection Views...라는 멋진 것을 발견했지만... 딥다이브하다가 실패했습니다 🥹 우선 중복 코드만 개선했습니다...관련 공식 문서
관련 WWDC영상
🙋♂️ 리뷰노트
✅ PR 체크리스트
XCConfig,노션,README)"API 개발 완료됐어요","XCConfig 값 추가되었어요")