Conversation
📝 WalkthroughWalkthroughImageGenerator.kt에서 이미지 처리 기능을 개선했습니다. 메모리 효율성을 높이기 위해 BitmapFactory의 inJustDecodeBounds를 활용한 두 단계 디코딩을 구현하고, calculateInSampleSize 헬퍼 함수로 최적의 샘플링 크기를 계산합니다. EXIF 메타데이터를 읽어 이미지 회전을 감지하고 디코딩 후 적용하는 기능을 추가했으며, 회전으로 생성된 새로운 비트맵에 대해 원본 비트맵을 회수합니다. 또한 calculateInSampleSize를 public 메서드로 노출하고 ImageProcessException으로 압축 실패를 처리하는 예외 처리를 확장했습니다. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 상세 리뷰긍정적인 부분메모리 최적화와 리소스 관리 개선을 훌륭하게 구현하셨습니다. 특히 다음 부분들이 좋습니다:
검토 권장사항다음 사항들을 더 확인해보시기 바랍니다:
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
core/ui/src/main/java/com/twix/ui/image/ImageGenerator.kt (1)
66-69: 타겟 해상도(1920x1080) 하드코딩에 대한 제안현재 FHD(1920x1080)가 하드코딩되어 있습니다. PR 설명에서 리뷰어에게 이 기준에 대한 의견을 요청하셨는데, FHD는 대부분의 모바일 화면에서 충분한 해상도이므로 합리적인 선택으로 보입니다.
다만, 향후 유지보수성을 위해 상수로 추출하는 것은 어떨까요?
♻️ 상수 추출 제안
companion object { private const val IMAGE_COMPRESSION_ERROR_MESSAGE = "Config: %s, Size: %dx%d" + private const val TARGET_WIDTH = 1920 + private const val TARGET_HEIGHT = 1080 }그리고 사용처에서:
- inSampleSize = calculateInSampleSize(bounds, 1920, 1080) + inSampleSize = calculateInSampleSize(bounds, TARGET_WIDTH, TARGET_HEIGHT)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@core/ui/src/main/java/com/twix/ui/image/ImageGenerator.kt` around lines 66 - 69, The code in ImageGenerator.kt hardcodes the 1920x1080 target resolution when creating BitmapFactory.Options (inSampleSize = calculateInSampleSize(bounds, 1920, 1080)); extract these magic numbers into named constants (e.g., TARGET_WIDTH and TARGET_HEIGHT) either as top-level constants or in a companion object of ImageGenerator, replace the literals in the calculateInSampleSize call with those constants, and update any related usages/comments to reference the new constants so the target resolution is configurable and easier to maintain.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@core/ui/src/main/java/com/twix/ui/image/ImageGenerator.kt`:
- Around line 60-74: In uriToBitmap, validate the first-pass bounds before
calling calculateInSampleSize: after the inJustDecodeBounds decode, check
bounds.outWidth and bounds.outHeight for <= 0 (or -1) and if invalid throw
ImageProcessException.DecodeFailedException(imageUri) so you don't proceed with
a bogus inSampleSize; then continue to create the real BitmapFactory.Options and
call calculateInSampleSize only when bounds are valid (reference symbols:
uriToBitmap, bounds.outWidth, bounds.outHeight, calculateInSampleSize,
ImageProcessException.DecodeFailedException).
---
Nitpick comments:
In `@core/ui/src/main/java/com/twix/ui/image/ImageGenerator.kt`:
- Around line 66-69: The code in ImageGenerator.kt hardcodes the 1920x1080
target resolution when creating BitmapFactory.Options (inSampleSize =
calculateInSampleSize(bounds, 1920, 1080)); extract these magic numbers into
named constants (e.g., TARGET_WIDTH and TARGET_HEIGHT) either as top-level
constants or in a companion object of ImageGenerator, replace the literals in
the calculateInSampleSize call with those constants, and update any related
usages/comments to reference the new constants so the target resolution is
configurable and easier to maintain.
이슈 번호
#119
작업내용
기존에 인증샷 업로드시 너무 시간이 오래걸리는 문제를 해결하기 위해 작업했어 😵💫
🥊 문제 상황
갤럭시 S25 기준 촬영 이미지 해상도는 4080x3060 이며 이를 원본 그대로 presigned URL을 통해 업로드하면서 최대 2.6초까지 소요되는 현상을 확인했어
📝 원인 분석
PresignedUploader에 로깅을 추가해 계측한 결과 다음 결과가 나왔어
이를 통해 고해상도 이미지를 리사이징 없이 그대로 업로드하면서 네트워크 전송 구간에서 병목이 발생하고 있음을 확인했어
🛎️ 개선 내용
BitmapFactory.Options(inJustDecodeBounds = true)를 사용해실제 디코딩 없이 이미지 크기만 먼저 측정
이번 작업을 진행하면서 공부한 내용을 블로그에 정리해봤어
결과물
PresignedUploader에 로그를 통해서 업로드에 걸리는 시간을 측정한 결과야 !
리뷰어에게 추가로 요구하는 사항 (선택)
샘플링 기준을 FHD 기준으로 잡았는는데 혹시 의견 있다면 편하게 말해줘 !
