Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Change requestNamedAnimationFrame to apply last change per frame instead of first #8799

Merged
merged 4 commits into from
Aug 13, 2024

Conversation

mister-ben
Copy link
Contributor

@mister-ben mister-ben commented Jul 14, 2024

Description

The current implementation of requestNamedAnimationFrame prevents multiple updates on a frame but by disregarding all but the first request per frame. This throttling behaviour is apparent when playing a very short video - if a timeupdate occurs just before the ended event, the progress bar position on the timeupdate is set at say 98% and 100% from the ended is discarded. Although #8633 removed the throttle from the ended handler itself, the throttle and non-throttled update can still both execute between frames.

Specific Changes proposed

Changes the implementation to apply only the last callback instead. If any exist they will be cancelled. There will still be only one update, but now it's the last.
Updates tests to reflect the changed behaviour.
Fixes #8782

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

@mister-ben mister-ben added the needs: discussion Needs a broader discussion label Jul 14, 2024
Copy link

codecov bot commented Jul 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.12%. Comparing base (c4007db) to head (17eb87e).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8799   +/-   ##
=======================================
  Coverage   83.12%   83.12%           
=======================================
  Files         120      120           
  Lines        8052     8052           
  Branches     1931     1931           
=======================================
  Hits         6693     6693           
  Misses       1359     1359           

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

@mister-ben mister-ben changed the title fix: Change named to apply last change per frame instead of first fix: Change requestNamedAnimationFrame to apply last change per frame instead of first Jul 14, 2024
@mister-ben mister-ben marked this pull request as ready for review July 17, 2024 13:09
@mister-ben mister-ben added the needs: LGTM Needs one or more additional approvals label Jul 22, 2024
@@ -1714,7 +1714,7 @@ class Component {
*/
requestNamedAnimationFrame(name, fn) {
if (this.namedRafs_.has(name)) {
return;
this.cancelNamedAnimationFrame(name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this still return as well or do we now want to execute the code below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous, if a raf with that name is already queued, it returned and did not add the new raf of this name.

Now if the named raf is queued, instead of returning, that queued one is cancelled, then the new raf is added.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks!

@mister-ben mister-ben removed needs: discussion Needs a broader discussion needs: LGTM Needs one or more additional approvals labels Aug 13, 2024
@mister-ben mister-ben merged commit e715145 into videojs:main Aug 13, 2024
11 checks passed
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.

Still facing issue with progress bar not completing 100%
2 participants