A profile switch runs one full-library query per remembered browse node #37
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Found by review on
67a14fb. Not reported from a car, and not a blocker for GitHub #78 — but GitHub #78 makes it materially more likely to be hit, so it is worth recording now rather than after somebody notices a slow account switch.The mechanism
AutoLibrary.remember()records everyseries/<id>andauthor/<id>node the browse tree has ever handed a head unit, intoemittedNodes. The set is never cleared, deliberately: an id dropped from it is a car still showing the previous profile's books, which is product priority 4. That part is correct and should stay.PlaybackService.observeBrowseTreeInvalidation()then does this on every profile switch:It calls
children()purely to obtain a count. AndAutoLibrary.books()is:No caching between calls.
observeAccessibleBooksreturnsBookWithRelations— authors, series memberships, tracks and chapters — for every visible book.So: one full accessible-library read per remembered node, per profile switch. A library with a thousand authors turns one account switch into a thousand full-library queries, which also delays the very notifications meant to clear the previous profile's cached titles.
Why GitHub #78 makes it worse
Before GitHub #78, Series and Authors lived one level inside Library, so a driver had to go Library → Series → a series to grow
emittedNodesat all. GitHub #78 promotes both to the browse root at the owner's request, so drilling into them is now a top-level action and the set will fill much faster in ordinary use.The change did not create the defect and does not need to fix it, but it removes the friction that was keeping it small.
What a fix looks like
The count is the only thing needed, so the expensive part is avoidable:
notifyChildrenChanged's count is advisory — the browser re-queries on notification. Verify that against Media3 before relying on it; if a plausible count suffices, the whole query disappears.Option 1 is the safe one. Option 2 is cheaper still but needs the Media3 behaviour checked rather than assumed — this branch has a poor record with assumed platform behaviour.
Acceptance
Related
AutoLibrary.remember()/browsableParents(),PlaybackService.observeBrowseTreeInvalidation()