-
Notifications
You must be signed in to change notification settings - Fork 0
[Fix] NetworkCallback의 onAvailable, onLost가 메인 스레드에서 실행되지 않아 발생하던 문제 수정 #433
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
base: develop
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @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
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this 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 콜백의 현재 로직은 여러 네트워크가 활성화된 시나리오에서 사용자에게 잘못된 정보를 제공할 수 있는 잠재적인 버그를 포함하고 있습니다. 이에 대한 수정 제안을 리뷰 코멘트로 남겼으니 확인 부탁드립니다.
| mainHandler.post { | ||
| dialog.show() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onLost 콜백은 등록된 NetworkRequest에 맞는 네트워크 중 하나가 끊겼을 때 호출됩니다. 예를 들어, Wi-Fi와 모바일 데이터가 모두 연결된 상태에서 Wi-Fi만 끊겨도 onLost가 호출될 수 있습니다. 이 경우, 모바일 데이터 연결은 여전히 활성화되어 있으므로 '네트워크 연결 안 됨' 다이얼로그를 표시하는 것은 사용자에게 혼란을 줄 수 있습니다.
다이얼로그를 표시하기 전에 getConnectivityStatus()를 통해 현재 활성화된 네트워크가 없는지 확인하는 로직을 추가하는 것이 좋습니다.
mainHandler.post {
if (getConnectivityStatus() == null) {
dialog.show()
}
}
kangyuri1114
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
급한 이슈라 Handler, Coroutine 사용은 크게 문제될 듯 없을 것 같아 어푸릅드립니다!
빠른대처감사합니다~
| mainHandler.post { | ||
| if (getConnectivityStatus() == null) { | ||
| // 네트워크 연결 안 되어 있을 때 | ||
| dialog.show() | ||
| } else { | ||
| // 네트워크 연결 되어 있을 때 | ||
| dialog.dismiss() | ||
| } |
There was a problem hiding this comment.
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()
}
}
아마 이렇게 하면 코루틴 사용해서 생명주기 부분이 더 안정성이 잇는 것으로 압니다..!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오우 그러네요! 제미니 반영까지 해서 올리겠습니당
|
릴리즈 3.2.0 어푸릅 주시면 |
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 처리 관련 문제 해결
https://developer.android.com/develop/connectivity/network-ops/reading-network-state?hl=ko
Describe your changes
Issue
To reviewers