Skip to content

Per-frame source and subtitle lists grow without bound on long-lived pages, each addition costing a page round trip and a broadcast to every tab #234

Closed

Description

@Nawid3333

Severity: medium

Where: chrome/background/background.mjs (addSource: frame.getSources().push({url, mode, headers, time}); onSourceRecieved runs scrapeCaptionsTags(frame) and sendSourcesToMainFramePlayers(frame) (a tabs.query({}) plus a SOURCES message carrying the whole list to every player-page tab) for every detected source; onHeadersReceived runs on every tab, On or Off)

What happens

Nothing trims trackedSources/trackedSubtitles except a navigation (FRAME_ADDED reset) or collectSources(frame, true) when a player asks. tests/e2e/ext-specs/source-length.e2e.mjs confirms that media segments named .mp4 (Shaka Packager style) are detected as MP4 sources of their own; HLS WebVTT subtitle segments (seg-N.vtt) go through isSubtitles the same way, one entry per unique URL.

A tab left Off (the normal state) plays a DASH/HLS title whose segments are seg-123.mp4/seg-123.vtt for two hours: about 3,600 sources, each holding the full requestHeaders array of its request (Cookie included), plus one SCRAPE_CAPTIONS round trip to the page and one chrome.tabs.query({}) + a SOURCES message carrying the whole growing list to every open player-page tab, per segment (O(n²) traffic). A single-page site that never navigates keeps this for the session.

Suggested fix

Cap each frame's lists (keep the newest N, e.g. 200, by time), and skip tracking a file whose StreamLengths.shape already has a tracked entry (the pieces of one stream need one representative, not all). Move scrapeCaptionsTags and sendSourcesToMainFramePlayers behind frame.tab.isOn / "a player tab exists" checks, or rate-limit the broadcast.

Confidence: high.


From a line-by-line code review of the tree at 41363fd (2026-10-02). Each claim above was checked against the source before filing; the reproduction steps and line references are as of that commit.


Generated by Claude Code

Activity

  1. added
    bugSomething isn't working
    code-reviewFound by the 2026-10-02 line-by-line review
    on Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcode-reviewFound by the 2026-10-02 line-by-line review

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions