Skip to content

Fix crash while loading installed apps in AppListFragment#15

Merged
Dev97633 merged 1 commit into
mainfrom
codex/fix-app-crashing-during-load
Apr 7, 2026
Merged

Fix crash while loading installed apps in AppListFragment#15
Dev97633 merged 1 commit into
mainfrom
codex/fix-app-crashing-during-load

Conversation

@Dev97633
Copy link
Copy Markdown
Owner

@Dev97633 Dev97633 commented Apr 7, 2026

Motivation

  • The app could crash while opening because installed-app scanning ran on the main thread and a single malformed package (bad label/icon/metadata) could throw and abort the entire load.
  • Loading work continued beyond the Fragment view lifecycle which could cause lifecycle-related crashes when the view was torn down during a long scan.

Description

  • Move installed-app loading off the main thread into a lifecycle-bound coroutine job stored in loadAppsJob and launched from viewLifecycleOwner.lifecycleScope using Dispatchers.IO (loadInstalledAppsSafely).
  • Cancel loadAppsJob in onDestroyView() to prevent work running after the view is destroyed.
  • Harden package parsing with mapNotNull { runCatching { ... }.getOrNull() } so a single problematic ApplicationInfo does not crash the entire list load.
  • Add safe fallbacks for packageName (orEmpty()) and appLabel (use package name when label retrieval fails), preserving the existing loadAppIconWithFallback behavior.

Testing

  • Attempted to run ./gradlew :app:assembleDebug but the environment`s wrapper script failed (permission and shell syntax errors) so a full build verification could not be completed here.
  • No other automated tests were executed in this environment; code changes were applied and committed locally.

Codex Task

@Dev97633 Dev97633 merged commit 335a433 into main Apr 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant