Skip to content

Conversation

@PeraSite
Copy link
Member

@PeraSite PeraSite commented Dec 26, 2025

Summary

https://console.firebase.google.com/project/eat-ssu-2023/crashlytics/app/android:com.eatssu.android/issues/406ced3d9ea75192abd7237fa65b2664?time=last-seven-days

ConnectivityManager.NetworkCallback의 콜백 함수들이 메인 스레드가 아닌 네트워크 연결 스레드에서 실행되어 발생하던 Dialog UI 처리 관련 문제 해결

image

https://developer.android.com/develop/connectivity/network-ops/reading-network-state?hl=ko

Describe your changes

Issue

  • Resolves #

To reviewers

@PeraSite PeraSite self-assigned this Dec 26, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @PeraSite, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 네트워크 연결 상태 변경을 감지하는 ConnectivityManager.NetworkCallback의 콜백 함수들이 메인 스레드가 아닌 백그라운드 스레드에서 실행되어 발생하던 UI 오류를 해결합니다. 특히, 네트워크 연결 상태에 따라 다이얼로그를 표시하거나 숨기는 작업이 올바르게 동작하지 않던 문제를 수정했습니다. 이제 모든 UI 관련 작업은 명시적으로 메인 스레드에서 처리되어 안정적인 사용자 경험을 제공합니다.

Highlights

  • 메인 스레드 문제 해결: ConnectivityManager.NetworkCallback의 onAvailable 및 onLost 콜백이 메인 스레드에서 실행되지 않아 발생하던 UI 관련 문제를 수정했습니다.
  • UI 작업 메인 스레드 강제 실행: 다이얼로그 표시/숨김과 같은 UI 관련 작업이 백그라운드 스레드에서 호출되지 않도록, Handler와 Looper를 사용하여 메인 스레드에서 실행되도록 변경했습니다.
  • Handler 도입: NetworkConnection 클래스에 mainHandler를 추가하여 UI 작업을 메인 스레드로 전달하는 데 사용합니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

안녕하세요. PR을 리뷰했습니다. NetworkCallback의 콜백 함수들이 백그라운드 스레드에서 실행되어 발생하던 UI 관련 크래시를 Handler를 사용해 메인 스레드에서 처리하도록 수정한 점이 좋습니다. 이는 문제를 해결하는 올바른 접근 방식입니다.

다만, onLost 콜백의 현재 로직은 여러 네트워크가 활성화된 시나리오에서 사용자에게 잘못된 정보를 제공할 수 있는 잠재적인 버그를 포함하고 있습니다. 이에 대한 수정 제안을 리뷰 코멘트로 남겼으니 확인 부탁드립니다.

Comment on lines +82 to +84
mainHandler.post {
dialog.show()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

onLost 콜백은 등록된 NetworkRequest에 맞는 네트워크 중 하나가 끊겼을 때 호출됩니다. 예를 들어, Wi-Fi와 모바일 데이터가 모두 연결된 상태에서 Wi-Fi만 끊겨도 onLost가 호출될 수 있습니다. 이 경우, 모바일 데이터 연결은 여전히 활성화되어 있으므로 '네트워크 연결 안 됨' 다이얼로그를 표시하는 것은 사용자에게 혼란을 줄 수 있습니다.

다이얼로그를 표시하기 전에 getConnectivityStatus()를 통해 현재 활성화된 네트워크가 없는지 확인하는 로직을 추가하는 것이 좋습니다.

        mainHandler.post {
            if (getConnectivityStatus() == null) {
                dialog.show()
            }
        }

Copy link
Member

@kangyuri1114 kangyuri1114 left a comment

Choose a reason for hiding this comment

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

급한 이슈라 Handler, Coroutine 사용은 크게 문제될 듯 없을 것 같아 어푸릅드립니다!
빠른대처감사합니다~

Comment on lines +67 to +74
mainHandler.post {
if (getConnectivityStatus() == null) {
// 네트워크 연결 안 되어 있을 때
dialog.show()
} else {
// 네트워크 연결 되어 있을 때
dialog.dismiss()
}
Copy link
Member

Choose a reason for hiding this comment

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

lifecycleScope.launch {
if (getConnectivityStatus() == null) {
dialog.show()
} else {
dialog.dismiss()
}
}

아마 이렇게 하면 코루틴 사용해서 생명주기 부분이 더 안정성이 잇는 것으로 압니다..!

Copy link
Member Author

Choose a reason for hiding this comment

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

오우 그러네요! 제미니 반영까지 해서 올리겠습니당

@kangyuri1114
Copy link
Member

릴리즈 3.2.0 어푸릅 주시면
그거 머지하고 이거 머지후에 3.2.1로 배포해주시면 될것같아요

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.

3 participants