Skip to content

Conversation

@HI-JIN2
Copy link
Member

@HI-JIN2 HI-JIN2 commented Oct 16, 2025

Summary

웹뷰 충돌 안정성을 추가 했습니다.
다만, 저는 이전 코드에서 아무리 빠르게 해봐도 앱이 강제 종료된 적이 없어서 ..
@PeraSite 님께서 풀 받아서 테스트 해주셔야 약효가 있는 코드인지 확인이 가능할 것 같습니다!

Issue

@HI-JIN2 HI-JIN2 self-assigned this Oct 16, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @HI-JIN2, 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은 웹뷰 사용 시 발생할 수 있는 렌더러 충돌로 인한 앱 강제 종료를 방지하고, 웹뷰 관련 자원을 보다 안정적으로 관리하기 위한 변경사항을 포함합니다. 특히 Android 8.0 이상 환경에서 웹뷰의 안정성을 향상시키고, 액티비티 생명주기에 맞춰 웹뷰 자원을 적절히 해제하여 전반적인 앱의 견고함을 높이는 데 중점을 둡니다.

Highlights

  • 웹뷰 렌더러 충돌 처리 추가: Android 8.0(Oreo) 이상에서 웹뷰 렌더링 프로세스 충돌 시 onRenderProcessGone 콜백을 통해 이를 감지하고 처리하는 로직을 구현했습니다.
  • 웹뷰 복구 로직 구현: 렌더러 충돌 발생 시 기존 웹뷰 인스턴스를 안전하게 파괴하고, 액티비티를 recreate()하여 웹뷰 기능을 복구하도록 하여 앱 강제 종료를 방지합니다.
  • 웹뷰 자원 해제 강화: onDestroy 메서드를 오버라이드하여 액티비티 종료 시 웹뷰의 로딩을 중지하고, webChromeClient를 null로 설정하며, 웹뷰를 명시적으로 destroy()하여 메모리 누수 및 잠재적 문제를 방지합니다.
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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds stability improvements to the WebView component to prevent app crashes when the WebView renderer process crashes. The changes implement crash handling and proper cleanup mechanisms.

  • Adds onRenderProcessGone callback to handle WebView renderer crashes gracefully
  • Implements proper WebView cleanup in onDestroy to prevent memory leaks
  • Adds logging for debugging WebView crashes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

// WebView를 재생성하거나 오류 안내 UI를 표시
recreate() // Activity 재시작으로 복구
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

Calling recreate() in onRenderProcessGone may cause infinite crash loops if the WebView consistently fails to render. Consider implementing a retry counter or showing an error message instead of automatically recreating the activity.

Copilot uses AI. Check for mistakes.
override fun onDestroy() {
binding.webview.apply {
stopLoading()
webChromeClient = null
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

The webChromeClient is being set to null but it was never explicitly set in this code. If it's set elsewhere, consider also setting webViewClient = null for consistency and complete cleanup.

Suggested change
webChromeClient = null
webChromeClient = null
webViewClient = null

Copilot uses AI. Check for mistakes.
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

안녕하세요. 웹뷰 안정성 개선을 위한 변경 사항 잘 보았습니다. 렌더러 충돌 시 앱이 강제 종료되는 것을 방지하기 위해 onRenderProcessGone 콜백을 구현하고, 액티비티 종료 시 WebView 리소스를 정리하여 메모리 누수를 방지하는 로직을 추가해주셨네요. 전반적으로 좋은 방향의 개선입니다.

다만, 몇 가지 추가 개선 사항을 제안드립니다. 렌더러 충돌이 반복될 경우 액티비티가 무한 재시작될 수 있는 가능성과, onDestroy에서 WebViewClient 참조를 해제하여 메모리 누수를 더 확실하게 방지하는 방법에 대해 의견을 남겼습니다. 확인 부탁드립니다.

}

// WebView를 재생성하거나 오류 안내 UI를 표시
recreate() // Activity 재시작으로 복구
Copy link
Contributor

Choose a reason for hiding this comment

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

high

웹페이지가 지속적으로 충돌을 일으키는 경우 recreate() 호출로 인해 액티비티가 무한 재시작 루프에 빠질 수 있습니다. 이는 앱을 사용할 수 없는 상태로 만들 수 있습니다.

이를 방지하기 위해 재시도 횟수를 제한하는 것이 좋습니다. savedInstanceState를 사용하여 재시작 횟수를 추적하고, 특정 횟수를 초과하면 액티비티를 종료하고 사용자에게 오류 메시지를 표시하는 로직을 추가하는 것을 고려해보세요.

Comment on lines +88 to +92
binding.webview.apply {
stopLoading()
webChromeClient = null
destroy()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

메모리 누수를 방지하기 위해 onDestroy에서 WebView 리소스를 해제하는 것은 매우 좋은 방법입니다. webChromeClientnull로 설정하는 것과 마찬가지로, onCreate에서 설정한 webViewClientnull로 설정하여 액티비티에 대한 참조를 안전하게 제거하는 것이 좋습니다. 이렇게 하면 익명 클래스로 생성된 WebViewClient가 액티비티의 컨텍스트를 계속 붙잡고 있는 것을 방지할 수 있습니다.

Suggested change
binding.webview.apply {
stopLoading()
webChromeClient = null
destroy()
}
binding.webview.apply {
stopLoading()
webViewClient = null
webChromeClient = null
destroy()
}

Copy link
Member

@PeraSite PeraSite left a comment

Choose a reason for hiding this comment

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

develop 브랜치로 돌려서 해봐도 문제 없는 걸 보니 그 때 당시만 제 기기에 문제가 있었나봐요..?!
안정성을 올렸다에 의의를 두면 될 것 같습니다 허허.. 고생하셨어요!!

@HI-JIN2 HI-JIN2 changed the title chore: 웹 뷰 안정성 추가 [Chore] 웹 뷰 안정성 추가 Oct 20, 2025
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.

👍

@PeraSite PeraSite merged commit 312b0a7 into develop Oct 23, 2025
1 check passed
@PeraSite PeraSite deleted the fix/webview-error branch October 23, 2025 08:19
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.

반복적으로 WebView를 열면 강제 종료됨

4 participants