Skip to content

fix: force text track updateDisplay to recalculate on playerresize#9160

Open
Frenzie wants to merge 1 commit intovideojs:mainfrom
Frenzie:playerresize-captions
Open

fix: force text track updateDisplay to recalculate on playerresize#9160
Frenzie wants to merge 1 commit intovideojs:mainfrom
Frenzie:playerresize-captions

Conversation

@Frenzie
Copy link
Copy Markdown
Contributor

@Frenzie Frenzie commented Mar 4, 2026

Otherwise processCues reuses the old position and size.

Description

  1. Go to https://legacy.videojs.org/advanced/?video=bipbop-advanced
  2. Activate the cc1 caption track
  3. Pause to more easily see the effect
  4. Activate fullscreen or resize the window such that the player resizes
  5. The caption position and size isn't recalculated

Screenshot_20260304_163748

Specific Changes proposed

Force recalculation in vtt.js in this function:

  // Determine if we need to compute the display states of the cues. This could
  // be the case if a cue's state has been changed since the last computation or
  // if it has not been computed yet.
  function shouldCompute(cues) {
    for (var i = 0; i < cues.length; i++) {
      if (cues[i].hasBeenReset || !cues[i].displayState) {
        return true;
      }
    }
    return false;
  }

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Change has been verified in an actual browser (Chrome, Firefox, IE)
    • Unit Tests updated or fixed
    • Docs/guides updated
    • Example created (starter template on JSBin)
    • Has no DOM changes which impact accessiblilty or trigger warnings (e.g. Chrome issues tab)
    • Has no changes to JSDoc which cause npm run docs:api to error
  • Reviewed by Two Core Contributors

@welcome
Copy link
Copy Markdown

welcome Bot commented Mar 4, 2026

💖 Thanks for opening this pull request! 💖

Things that will help get your PR across the finish line:

  • Run npm run lint -- --errors locally to catch formatting errors earlier.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

Otherwise processCues reuses the old position and size.
@Frenzie Frenzie force-pushed the playerresize-captions branch from 7694344 to 0e095b3 Compare March 4, 2026 15:35
@Frenzie Frenzie changed the title Force text track updateDisplay to recalculate on playerresize fix: force text track updateDisplay to recalculate on playerresize Mar 4, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.32%. Comparing base (9d2101e) to head (0e095b3).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/js/tracks/text-track-display.js 80.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9160      +/-   ##
==========================================
- Coverage   84.32%   84.32%   -0.01%     
==========================================
  Files         120      120              
  Lines        8153     8157       +4     
  Branches     1964     1967       +3     
==========================================
+ Hits         6875     6878       +3     
- Misses       1278     1279       +1     

☔ View full report in Codecov by Sentry.
📢 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.

@mister-ben
Copy link
Copy Markdown
Contributor

mister-ben commented Mar 11, 2026

I can't reproduce the issue on Chrome or Firefox. It's resizing without your change. Is there anything more to know to reproduce that?

@Frenzie
Copy link
Copy Markdown
Contributor Author

Frenzie commented Mar 11, 2026

That means you selected any of the subtitle tracks, not the cc1 caption track. ;-)

It happens in all browsers because the issue is that it purposefully skips computing the size/position when resizing.

@mister-ben
Copy link
Copy Markdown
Contributor

Sorry, I see now!

@mister-ben mister-ben added the needs: LGTM Needs one or more additional approvals label Mar 12, 2026
@Frenzie
Copy link
Copy Markdown
Contributor Author

Frenzie commented Mar 12, 2026

No problem and thanks! While I have your attention, would you mind taking a look at my PRs against vtt.js?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs: LGTM Needs one or more additional approvals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants