perf(home): Load Home's rails in parallel, and from saved data when the pool is slow #40

Merged
namillis merged 3 commits from perf/home-rails into main 2026-11-10 02:51:22 +00:00
Owner

Merge #38 and #39 first. This branch has both merged in: it uses #38's ProviderFileStore and #39's isLiveNow(name, pool). Until they land, this diff includes their commits; afterwards it shows only this PR's changes.

What was wrong

Home's first screen waited for one request after another: the categories, then the live sports list, then each of the six category rails. On the emulator that took 0.95-2.0 s. Whenever the pool paused (a rebuild, or the first minute after a deploy), Home waited out the whole pause.

What changed

  • HomeViewModel.kt requests the live list and every rail at once after the categories, with the pool check running alongside the categories request. The live list is usually also one of the rails, so it's requested once. That's two round trips however many rails there are. refreshIfStale uses the same path.
  • ProviderRepository.kt saves each non-empty categories answer per provider in the ProviderFileStore (savedLiveCategories), and only writes when the list changed. An empty answer, which is what an HTTP error returns, never replaces it. forgetProvider deletes it with the provider's other files.
  • If the provider hasn't answered within 1.5 s, Home builds its rails from the saved categories and the full channel list, which is loaded from disk by then (HomeLists.railsFromChannels in HomeLists.kt). It swaps in the provider's rails when they land. The pool lists each category's channels in the full list in the same order as the category's own list; I checked all 43 categories. Until the swap, the live list from a saved channel list has no game details and may be out of date.
  • If the provider fails after saved rails are up, they stay up and the provider is checked again on the next load. If it fails before then, Home still shows its error, so failover to a backup provider works as before.

Verified

  • testDebugUnitTest (646 tests), lintDebug and assembleDebug pass. HomeListsTest.kt covers rails built from the full list (order, pins, the live list only on the pool), and SavedCategoriesTest.kt covers saving, an empty or failed answer, M3U, delete and the file name.

  • LiveWireTV_API34 emulator with the tv3 login, temporary logging (removed), 6 launches each, alternating builds. Time until Home's first rails:

    Times Median
    main 945, 969, 1,039, 1,122, 1,486, 2,036 ms 1,081 ms
    This branch 719, 756, 785, 791, 797 ms; one launch hit a real pool pause and showed saved rails at 1,652 ms, swapped 0.6 s later 788 ms

    On this branch the categories request took about 230 ms and all seven rail requests together about 445 ms. main makes one request fewer, because it doesn't find Live Sports (#39).

  • Pool pause simulated with a 6 s delay on the provider's rails (throwaway build): Home showed rails from saved data at 1.65 s, with the live list showing channel names and guide titles. At about 6.5 s the pool's rails replaced them, with the game details. With the saved channel list deleted, Home used the freshly downloaded full list the same way.

**Merge #38 and #39 first.** This branch has both merged in: it uses #38's `ProviderFileStore` and #39's `isLiveNow(name, pool)`. Until they land, this diff includes their commits; afterwards it shows only this PR's changes. ## What was wrong Home's first screen waited for one request after another: the categories, then the live sports list, then each of the six category rails. On the emulator that took 0.95-2.0 s. Whenever the pool paused (a rebuild, or the first minute after a deploy), Home waited out the whole pause. ## What changed - `HomeViewModel.kt` requests the live list and every rail at once after the categories, with the pool check running alongside the categories request. The live list is usually also one of the rails, so it's requested once. That's two round trips however many rails there are. `refreshIfStale` uses the same path. - `ProviderRepository.kt` saves each non-empty categories answer per provider in the `ProviderFileStore` (`savedLiveCategories`), and only writes when the list changed. An empty answer, which is what an HTTP error returns, never replaces it. `forgetProvider` deletes it with the provider's other files. - If the provider hasn't answered within 1.5 s, Home builds its rails from the saved categories and the full channel list, which is loaded from disk by then (`HomeLists.railsFromChannels` in `HomeLists.kt`). It swaps in the provider's rails when they land. The pool lists each category's channels in the full list in the same order as the category's own list; I checked all 43 categories. Until the swap, the live list from a saved channel list has no game details and may be out of date. - If the provider fails after saved rails are up, they stay up and the provider is checked again on the next load. If it fails before then, Home still shows its error, so failover to a backup provider works as before. ## Verified - `testDebugUnitTest` (646 tests), `lintDebug` and `assembleDebug` pass. `HomeListsTest.kt` covers rails built from the full list (order, pins, the live list only on the pool), and `SavedCategoriesTest.kt` covers saving, an empty or failed answer, M3U, delete and the file name. - LiveWireTV_API34 emulator with the tv3 login, temporary logging (removed), 6 launches each, alternating builds. Time until Home's first rails: | | Times | Median | |---|---|---| | `main` | 945, 969, 1,039, 1,122, 1,486, 2,036 ms | 1,081 ms | | This branch | 719, 756, 785, 791, 797 ms; one launch hit a real pool pause and showed saved rails at 1,652 ms, swapped 0.6 s later | 788 ms | On this branch the categories request took about 230 ms and all seven rail requests together about 445 ms. `main` makes one request fewer, because it doesn't find Live Sports (#39). - Pool pause simulated with a 6 s delay on the provider's rails (throwaway build): Home showed rails from saved data at 1.65 s, with the live list showing channel names and guide titles. At about 6.5 s the pool's rails replaced them, with the game details. With the saved channel list deleted, Home used the freshly downloaded full list the same way.
perf(providers): Save the pool's feature list and use it at launch
All checks were successful
CI / test (pull_request) Successful in 7m12s
b99cfcb746
Every launch had to get a pool_info answer within 3 seconds before the
app used retry, stop, sources, event_info or guide_window. When the
pool was slow (a rebuild pause, or the first minute after a deploy), the
app treated it as a plain panel for a minute and downloaded the full
guide.

Each real pool_info answer is now saved per provider in a new
ProviderFileStore, named by hashes of the provider id and its URL and
login, like the channel list cache. A launch uses the saved list at
once and asks pool_info again in the background; the answer replaces
it. A real answer is the pool's feature list, or empty for a plain
panel (a 404, an accepted login with no pool shape).

A timeout, a 429, a 5xx, a network error or a refused login is not an
answer: it keeps the saved list and the check is tried again after a
minute (a 429's Retry-After). A refused login used to be cached as
"plain panel" for the run; with nothing saved it now counts as plain
for a minute, like a timeout. With nothing saved, the first call still
waits for the answer, as before.

Only one pool_info check runs at a time per provider, so a launch no
longer sends two. Editing or deleting a provider deletes its saved list.
fix(home): Find the pool's live games list under its new name, Live Sports
All checks were successful
CI / test (pull_request) Successful in 6m28s
943edd3344
On 2026-11-06 the pool renamed its Live Now category to Live Sports
(same category id) and added Popular on TV before it. The app found
the list by the name "Live Now", so since then:

- Home showed Live Sports as an ordinary category: no live dot, not
  first in the list menu, and not the default list.
- Sports never found the pool's event channels, so a live game's Watch
  option fell back to a channel matched by name (for example US - ESPN)
  instead of the event channel, which fails over between providers.

HomeLists.isLiveNow now also accepts "Live Sports", but only for a
provider whose pool_info lists event_info: plain panels use that name
for ordinary channels.
perf(home): Load Home's rails in parallel, and from saved data when the pool is slow
All checks were successful
CI / test (pull_request) Successful in 6m50s
7dbbc68d7a
Home's first screen waited for one request after another: the
categories, the live sports list, then each of the six category rails.
That was about 0.65-1.3 s on the emulator, and the whole wait whenever
the pool paused.

The live list and every rail are now requested at once after the
categories (the live list is often also a rail, so it's asked for
once), and the pool check runs alongside the categories request. That
is two round trips, however many rails.

Each non-empty categories answer is saved per provider in the
ProviderFileStore. When the provider hasn't answered within 1.5 s, Home
builds its rails from the saved categories and the full channel list
(already loaded from disk by then), then swaps in the provider's rails
when they land. The pool lists each category's channels in the full
list in the same order as the category's own list. A failed answer
after saved rails are up keeps them and has the provider checked again
on the next load; a failure before that still shows the error, as
before, so failover to a backup provider works as it did.
Merge remote-tracking branch 'origin/main' into perf/home-rails
All checks were successful
CI / test (pull_request) Successful in 32s
0ccc3b7560
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
namillis/LiveWireTV!40
No description provided.