Skip to content

refactor(core): harden exception safety, coroutine cancellation, and memory optimization - #580

Open
Himanth-reddy wants to merge 1 commit into
ProdigyV21:mainfrom
Himanth-reddy:chore/all-pr-refactors-squashed
Open

refactor(core): harden exception safety, coroutine cancellation, and memory optimization#580
Himanth-reddy wants to merge 1 commit into
ProdigyV21:mainfrom
Himanth-reddy:chore/all-pr-refactors-squashed

Conversation

@Himanth-reddy

Copy link
Copy Markdown
Collaborator

Summary

This pull request consolidates and squashes core stability, exception safety, and coroutine cancellation refactor improvements across data repositories, viewmodels, and UI components.

Key Changes

  • Exception Safety & Coroutine Cancellation:
    • Replaced broad runCatching / catch (e: Exception) blocks in CloudSyncRepository, HomeServerRepository, WatchHistoryRepository, HttpLocalScraperRuntime, and IptvPlaybackUrlResolver to ensure CancellationException is rethrown correctly.
    • Added cancellation-safe handling across DetailsViewModel, TvViewModel, LoginViewModel, and WatchlistViewModel.
  • JSON Error Handling & Diagnostics:
    • Hardened JSON parsing in AuthRepository and CloudSyncRepository with diagnostic logging via AppLogger.recordException.
    • Used stored Trakt auth check traktRepository.isAuthenticated.first() instead of triggering offline network refresh during startup profile evaluation.
  • Memory & Parsing Optimizations:
    • Extracted compiled regex instances to singleton objects (StreamSourceAttributionRegexes, AutoPlayRegexes) to reduce GC pressure and repeated allocations during stream resolution and source attribution.
    • Hardened response body closing and safe parsing in OkHttpProvider, WatchlistRepository, and stream resolution layers.
  • CI Workflows:
    • Modernized GitHub Actions workflow action pins and steps.

Verification

  • ./gradlew :app:compileSideloadDebugKotlin :app:testSideloadDebugUnitTest passed successfully (BUILD SUCCESSFUL).

…iew fixes

- PR #59: harden exception safety and json parsing in scraper & repository layers
- PR #61: optimize memory by extracting regexes and harden json error handling
- PR #62: harden exception safety, Trakt auth checks, and watch history cancellation
- PR #63: preserve coroutine cancellation across sync, home server, and catalog layers
- PR #64: propagate cancellation across viewmodels and UI components
- PR #65: optimize stream parsing layers and source attribution regexes
- PR #66: harden exception safety and edge-case validation in watchlist & network layers
@github-actions github-actions Bot added area: android Changes to the Android app or Gradle build area: ci Changes to CI/CD and repository automation labels Aug 17, 2026
@ProdigyV21

Copy link
Copy Markdown
Owner

Thanks for putting this cleanup together. The cancellation/error-handling work looks useful, and I verified that the exact merge compiles for both Play and Sideload and passes the Sideload unit tests.

Before merging, could you please fix these two points:

  1. In IptvPlaybackUrlResolver.kt, remove the new private looksLikeHlsPlaybackUrl() helper and keep using the existing complete top-level detector. The private version shadows it and only recognizes .m3u8, so URLs identified through /hls/, output=m3u8, or format=hls may be passed to Media3 with the wrong stream type and fail playback.
  2. In build-check.yml, restore the required-credential validation instead of leaving every check commented out. This does not affect runtime, but it makes signed-build failures much harder to diagnose when a secret is missing.

After those two adjustments, this should be in good shape to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: android Changes to the Android app or Gradle build area: ci Changes to CI/CD and repository automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants