fix: Task 4 완료 - LunaticLauncher Toast 및 LauncherActivity onDestroy 메모리 누수 수정

- LunaticLauncher.kt: companion object의 정적 Toast 강참조(var toast: Toast?)로 인한 Activity Context 누수 제거 -> applicationContext 기반 WeakReference<Toast>로 전환 및 이전 Toast 취소 처리 유지
- LauncherActivity.kt onDestroy():
  * sActivity === this 조건으로 정적 Activity 참조 null 해제
  * hiddenLoader 내 모든 GeckoWeb 세션(session?.close(), releaseSession()) 종료 및 clear() 처리
  * callBackHandler.removeCallbacksAndMessages(null) 호출로 대기 중인 콜백 제거
  * connectivityManager.unregisterNetworkCallback 호출 시 ::connectivityManager.isInitialized 및 예외 방어 추가
- TODO.md: 1-2 항목 완료 처리
- 검증: ./gradlew :app:compileDebugKotlin 빌드 성공 확인 (6s)
This commit is contained in:
2026-11-16 11:12:16 +09:00
parent 244d3cee14
commit 8c278c2fc4
3 changed files with 29 additions and 10 deletions
+1 -1
View File
@@ -43,7 +43,7 @@
- `app/src/main/kotlin/bums/lunatic/launcher/home/RssHome.kt:95` — `var home: RssHome? = null` 정적 참조로 Fragment 및 연결된 View/Binding 누수 위험.
- **작업**: 정적 Activity/Fragment 참조를 `WeakReference` 또는 이벤트 버스(`SharedFlow`/`ViewModel`)로 대체하고, 최소한 `onDestroy()`/`onDestroyView()`에서 `null` 처리.
- [ ] **1-2. 전역 `Toast` 인스턴스의 `Context` 누수 해결**
- [x] **1-2. 전역 `Toast` 인스턴스의 `Context` 누수 해결**
- `app/src/main/kotlin/bums/lunatic/launcher/LunaticLauncher.kt:62-75` — `companion object`의 `var toast: Toast? = null`에 `Context.toast()` 호출 시 전달된 `Context`(Activity일 수 있음)로 `Toast(this)`를 생성해 정적으로 유지함.
- **작업**: `Toast(applicationContext)`를 사용하거나 매 호출 시 지역 `Toast`를 생성하고 기존 `toast?.cancel()` 후 참조를 유지하지 않도록 변경.