Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,34 +1,49 @@
package com.eatssu.android.presentation.mypage.terms

import android.os.Bundle
import android.webkit.RenderProcessGoneDetail
import android.webkit.WebView
import android.webkit.WebViewClient
import com.eatssu.android.databinding.ActivityWebviewBinding
import com.eatssu.android.presentation.base.BaseActivity
import com.eatssu.common.EventLogger
import com.eatssu.common.enums.ScreenId
import timber.log.Timber


class WebViewActivity :
BaseActivity<ActivityWebviewBinding>(
ActivityWebviewBinding::inflate,
ScreenId.EXTERNAL_INQUIRE // shouldLogScreenId가 false라 미사용
) {


private var URL = ""
private var TITLE = ""

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)



binding.webview.apply {
webViewClient = WebViewClient()

// localStorage 사용 시
// webView.settings.domStorageEnabled = true
webViewClient = object : WebViewClient() {

// 렌더러 충돌 시 호출되는 콜백 (Android 8.0 이상)
override fun onRenderProcessGone(
view: WebView?,
detail: RenderProcessGoneDetail
): Boolean {
Timber.e("⚠WebView renderer crashed! Did renderer die: ${detail.didCrash()}")

// view가 null이거나 이미 죽은 상태이므로 안전하게 정리
try {
view?.destroy()
} catch (e: Exception) {
Timber.e(e, "Error while destroying crashed WebView")
}

// 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.
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를 사용하여 재시작 횟수를 추적하고, 특정 횟수를 초과하면 액티비티를 종료하고 사용자에게 오류 메시지를 표시하는 로직을 추가하는 것을 고려해보세요.

return true // 앱 강제 종료 방지
}
}

// 웹 페이지에서 새 창을 열 수 있도록 설정
// Notion 페이지 = DOM Storage(domStorageEnabled) 없으면 동작 불가
Expand Down Expand Up @@ -69,5 +84,14 @@ class WebViewActivity :
Timber.d("WebViewActivity screen view logging: $screenId")
}

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.
destroy()
}
Comment on lines +88 to +92
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()
}

super.onDestroy()
}

override fun shouldLogScreenId() = false
}
}