Skip to content

feat: serve fully-collected playlists from cache so no helper is ever needed - #680

Merged
KrX3D merged 1 commit into
mainfrom
feat/playlist-full-cache
Aug 29, 2026
Merged

feat: serve fully-collected playlists from cache so no helper is ever needed#680
KrX3D merged 1 commit into
mainfrom
feat/playlist-full-cache

Conversation

@KrX3D

@KrX3D KrX3D commented Aug 29, 2026

Copy link
Copy Markdown
Owner

This is the commit that was missing from #679. That PR was merged while it still contained only the revert, so v1.15.570 has the revert but not this — which is why the log showed prefetch_ready {hasMore:false, aborted:false} firing with no full_cache.* entries at all. My mistake in how I pushed it.

Removes helper tiles entirely for playlists the collector fetches in full.

The initial page response is the one place the "a continuation must append at least one item" rule doesn't apply. Give it the whole playlist with continuations nulled and there's nothing left to load — so the keep-one branch never runs, no helper is created, and nothing gets stranded in the virtual list's data model (654577e).

Ordering is handled by collecting as now, caching by playlist hash, and reloading once; the reloaded initial response is served complete from cache. Revisiting the playlist later in the session hits the cache with no reload.

Guards: only a complete collection is cached (a partial one would render truncated with no token to load the rest); reload fires at most once per playlist and not if you navigated away; cache bounded to 3 playlists.

Expected log on the next test: full_cache.storedfull_cache.reloadingfull_cache.injected, and no keep-one.register.

… needed

Removes the helper tiles entirely for playlists the background collector
manages to fetch in full, which is the only way left to be rid of the
stranded blank slots.

Why this shape. A helper only exists because a continuation response must
append at least one item or YouTube stops asking for more (proved by the
previous PR, which returned [] and stalled a 68-video playlist after two
batches). The initial page response is the one place that constraint does
not apply: give it the WHOLE playlist and null its continuations, and
there is nothing left to load, so no keep-one branch runs and no helper is
ever created. Nothing then gets stranded in the virtual list's data model,
which is what made every DOM-side attempt futile (654577e).

The ordering problem is that on a first visit the full list only exists
after collection finishes, long after the initial response rendered. So:
collect as now, cache the result keyed by playlist hash, and reload the
page once. The reloaded initial response is served from cache, complete,
with continuations nulled. Revisiting that playlist later in the session
hits the cache immediately and skips both the collection and the reload.

Reloading per batch — the obvious variant — cannot work: a reload
re-fetches the FIRST page, so it would loop on batch 1 forever.

Details:
- _collectAll only ever returns the CONTINUATION batches (53 of 68 on the
  measured playlist), so adblock.js hands the raw initial batch over via
  noteInitialPlaylistContents to make the cached list complete from item 1.
- Only a COMPLETE collection is cached (no continuation token left, not
  aborted). Caching a partial list would render a truncated playlist with
  no token to load the rest.
- Reload fires at most once per playlist key, and not at all if the user
  navigated away while collecting.
- Cache is bounded to 3 playlists, evicting oldest — these are full
  renderer objects and this runs on a TV.
- resolveCommand is reached through a window global rather than an ES
  import: playlistBatchCollect.js must evaluate before adblock.js to
  capture JSON.parse ahead of its patch, and importing resolveCommand
  (which pulls in settings/UI) would risk reordering that.

Cost is one visible reload the first time a playlist is opened. Only
active with enablePlaylistBatchCollect on.
@KrX3D
KrX3D merged commit 122aa31 into main Aug 29, 2026
3 checks passed
@KrX3D
KrX3D deleted the feat/playlist-full-cache branch August 29, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant