perf(home): Load Home's rails in parallel, and from saved data when the pool is slow #40
Loading…
Reference in a new issue
No description provided.
Delete branch "perf/home-rails"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Merge #38 and #39 first. This branch has both merged in: it uses #38's
ProviderFileStoreand #39'sisLiveNow(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.ktrequests 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.refreshIfStaleuses the same path.ProviderRepository.ktsaves each non-empty categories answer per provider in theProviderFileStore(savedLiveCategories), and only writes when the list changed. An empty answer, which is what an HTTP error returns, never replaces it.forgetProviderdeletes it with the provider's other files.HomeLists.railsFromChannelsinHomeLists.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.Verified
testDebugUnitTest(646 tests),lintDebugandassembleDebugpass.HomeListsTest.ktcovers rails built from the full list (order, pins, the live list only on the pool), andSavedCategoriesTest.ktcovers 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:
mainOn this branch the categories request took about 230 ms and all seven rail requests together about 445 ms.
mainmakes 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.