Skip to content

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

Merged
ProdigyV21 merged 2 commits into
ProdigyV21:mainfrom
Himanth-reddy:chore/all-pr-refactors-squashed
Aug 24, 2026
Merged

refactor(core): harden exception safety, coroutine cancellation, and memory optimization#580
ProdigyV21 merged 2 commits 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).

@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.

@philstanway-oss

Copy link
Copy Markdown
Collaborator

@Himanth-reddy @ProdigyV21 where are we with this, can i close it out?

@Himanth-reddy

Copy link
Copy Markdown
Collaborator Author

I don’t have time right now. I’ll make another commit according to the requested changes when I get some time

@philstanway-oss

Copy link
Copy Markdown
Collaborator

@Himanth-reddy thanks for the update

…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
@Himanth-reddy
Himanth-reddy force-pushed the chore/all-pr-refactors-squashed branch from 277d1cb to 0e08cfa Compare August 23, 2026 10:49
@ProdigyV21
ProdigyV21 merged commit 9ba76ab into ProdigyV21:main Aug 24, 2026
10 checks passed
@Himanth-reddy
Himanth-reddy deleted the chore/all-pr-refactors-squashed branch August 31, 2026 12:38
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.

3 participants