Skip to content

Fix inband metadata cue cleanup during buffer removal - #1615

Open
ArianMoeini wants to merge 1 commit into
videojs:mainfrom
ArianMoeini:fix/share-inband-text-tracks
Open

ArianMoeini wants to merge 1 commit into
videojs:mainfrom
ArianMoeini:fix/share-inband-text-tracks

Conversation

@ArianMoeini

Copy link
Copy Markdown

Description

The controller and its segment loaders receive different copies of the plain inbandTextTracks map because merge() deep-copies it. The controller adds metadata tracks to its map, but segment eviction looks in the loader copy, leaving old cues behind. This fixes #1591.

Specific changes proposed

  • Pass loader settings with a shallow copy so the controller and loaders share the track map.
  • Add a regression that creates a controller metadata cue and verifies segment removal clears it.

Requirements checklist

  • Bug fixed
  • Unit test added
  • npm test lint and bundle steps passed (0 errors; existing warnings)
  • Chrome browser suite: 1,428 passed, 7 skipped

Closes #1591.

@codecov

codecov Bot commented Oct 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.00%. Comparing base (a9f9d7a) to head (98fe830).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1615   +/-   ##
=======================================
  Coverage   84.00%   84.00%           
=======================================
  Files          44       44           
  Lines       11713    11713           
  Branches     2625     2625           
=======================================
  Hits         9840     9840           
  Misses       1873     1873           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@javierarams

Copy link
Copy Markdown
Contributor

Thanks @ArianMoeini! The diagnosis is right, but sharing the map causes two problems. I reproduced both in Chrome with a stream that has demuxed alternate audio, 608 captions, ID3 and DATERANGE.

  1. Switching audio track calls resetEverything() on the audio loader only, and remove(0, duration) now clears every caption, ID3 and DATERANGE cue (60/60/20 go to 0/0/0). The video buffer stays, so captions are gone for everything already buffered. Fix: only clear inband cues from the main loader.
if (force || this.loaderType_ === 'main') {
  for (const track in this.inbandTextTracks_) {
    removeCuesFromTrack(start, end, this.inbandTextTracks_[track]);
  }
}
  1. Any main loader remove() now also deletes DATERANGE cues from metadataTrack_, and DateRangesStorage never adds them again. After a seek out of the buffer or the back buffer trim they are lost for good (20 go to 0). Could we skip cues with type === 'com.apple.quicktime.HLS' there, since they come from the playlist and not the segment?

A test that adds caption and metadata cues and calls audioSegmentLoader_.remove(0, 4) would catch the first one. A rebase on main would also fix the flaky onResponse tests.

@javierarams javierarams self-assigned this Nov 23, 2026

This branch has not been deployed

No deployments
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.

Bug: Memory leak in Timed Metadata TextTrack cues

2 participants