Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ ⚡ Improve uploading image #375

Merged
merged 8 commits into from
Sep 26, 2024
Merged

♻️ ⚡ Improve uploading image #375

merged 8 commits into from
Sep 26, 2024

Conversation

github-actions[bot]
Copy link
Contributor

Original issue description
  • resizing Image

closes #374

- utilization of coroutine
- image compress
- PNG -> JPEG
Copy link
Contributor

@kmkim2689 kmkim2689 left a comment

Choose a reason for hiding this comment

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

하디 이미지 회전 관련하여 수고 많으셨습니다!
당시 원인을 알 수 없는 오류였는데 해결해서 정말 다행이네요.
몇 가지 피드백 남겨보았습니다.
고생 많으셨습니다!

viewModel.fetchImageUri(File(currentPhotoPath!!).name)
} else {
showSnackBar(getString(R.string.image_selection_failed))
lifecycleScope.launch {
Copy link
Contributor

Choose a reason for hiding this comment

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

Fragment에서 lifecyleScope를 직접 사용하면 메모리 누수의 우려가 있습니다. viewLifecycleOwner.lifecycleScope를 사용하는 것이 좋아보입니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

좋은 의견 감사드립니다!

하지만 viewLifecycleOwner.lifecycleScope를 사용하였을시에 이미지 업로드 하는 과정에서 Android Home으로 갔다오면 코루틴이 중단이 되어서 업로드가 안되기 때문에 이렇게 한것인데 어떤 의견이신가요?

@@ -120,11 +125,20 @@ class RecipeMakingFragment : Fragment() {
}

private fun processImageUri(uri: Uri) {
Copy link
Contributor

Choose a reason for hiding this comment

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

함수 이름과는 달리 함수 내부에서는 로컬 사진의 uri를 기반으로 presignedUrl을 가져올 뿐만 아니라 압축까지 진행하는데, 함수 이름을 변경하거나 두 개의 함수로 분리하는 것이 좋아보여용ㅎㅎ

Copy link
Contributor

Choose a reason for hiding this comment

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

2개로 나누기는 어려워 보여서 compressAndFetchPresignedUrl로 네이밍 변경했습니다!

val compressedFile = imageUtils.compressAndResizeImage(uri)
currentPhotoPath = compressedFile.absolutePath

withContext(Dispatchers.Main) {
Copy link
Contributor

Choose a reason for hiding this comment

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

해당 작업을 Main Dispatcher로 Context Switching 하신 이유가 궁금합니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

음.. 이건 UI작업이라고 생각했는데 아닌가요..? 허허

}
} catch (e: IOException) {
e.printStackTrace()
withContext(Dispatchers.Main) {
Copy link
Contributor

Choose a reason for hiding this comment

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

이건 인정입니다!

val compressedFile = imageUtils.compressAndResizeImage(uri)
currentPhotoPath = compressedFile.absolutePath

withContext(Dispatchers.Main) {
Copy link
Contributor

Choose a reason for hiding this comment

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

위의 리뷰와 동일합니다.


fun processImageUri(uri: Uri): String? {
return try {
// fun processImageUri(uri: Uri): String? =
Copy link
Contributor

Choose a reason for hiding this comment

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

제거 부탁드립니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

제거하기에는 압축하지 않은 파일을 올릴때도 필요할것 같아서 남겨둔건데 주석은 다 없앨까요?

Copy link
Contributor

Choose a reason for hiding this comment

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

넵! 커밋 기록에 남아있기 때문에 상관 없을 것 같아요!

outputStream.flush()
outputStream.close()

originalBitmap.recycle()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an advanced call, and normally need not be called, since the normal GC process will free up this memory when there are no more references to this bitmap.

인터페이스 문서 상에서, GC가 알아서 처리해줘서 recycle()은 딱히 호출할 필요는 없다고 하는데 지우는 것은 어떻게 생각하시나요?

Copy link
Contributor

Choose a reason for hiding this comment

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

혹시라도 메모리 누수가 있을 것 같아서 바로 없애려고 한건데 우선 지워보겠습니다!

Copy link
Contributor

@Hogu59 Hogu59 left a comment

Choose a reason for hiding this comment

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

하디 안녕하세요!

카메라 리팩토링 쉽지 않았을텐데 고생 많았습니다.
케이엠이 리뷰 남겨준 내용만 반영하면 될 것 같아 저는 어프루브 하도록 하겠습니다.

고생 많으셨습니다! 🙇

Copy link
Contributor

@kmkim2689 kmkim2689 left a comment

Choose a reason for hiding this comment

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

수고 많으셨읍니다 하디!

@ii2001 ii2001 merged commit 075b921 into an/dev Sep 26, 2024
2 checks passed
@ii2001 ii2001 deleted the an/feat/374 branch September 26, 2024 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AN Android ♻️ refactor refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants