Skip to content

Background audio analyzer can be orphaned: a running 8x player survives source changes and can never be stopped #193

Closed

Description

@Nawid3333

Severity: medium

Where: chrome/player/modules/analyzer/AudioAnalyzer.mjs (startBackgroundAnalyzer: the onDone callback ends with an unconditional this.backgroundAnalyzerPlayer = null;; the post-load check is only if (newSource !== this.backgroundAnalyzerSource) { backgroundAnalyzerPlayer.destroy(); return; }; status is set RUNNING only after the load)

Failure scenarios

(a) FineTimeControls opened: start A loading (status still IDLE); tool closed: stopBackgroundAnalyzer (source = null); tool reopened and play: start B for the same source (allowed: status IDLE, source null). A resolves, source matches, assigned. B resolves, also matches, this.backgroundAnalyzerPlayer = B; A keeps running (rAF loop, its own AudioContext, 8x looping playback, fragment downloads) and nothing references it; reset()/stopBackgroundAnalyzer can never destroy it.

(b) Source changes while A loads; B (new source) is assigned first; A resolves, is destroyed, and its onDone sets backgroundAnalyzerPlayer = null: B is orphaned, and the status stuck at RUNNING refuses any later start for that source.

Suggested fix

A generation counter (const gen = ++this.startGen before the await; after it if (gen !== this.startGen) { player.destroy(); return; }), and in onDone null the field only when this.backgroundAnalyzerPlayer === backgroundAnalyzerPlayer. vadLifecycle.test.mjs's AudioAnalyzer block would take such a test.

Confidence: high on the code; medium on frequency.


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