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

perf: throttle more timers and use native bind #6142

Merged
merged 4 commits into from
Jul 30, 2019
Merged

Conversation

brandonocasey
Copy link
Contributor

Description

This pull request contains various performance improvement broken up into separate commits.

@@ -88,7 +103,7 @@ class TimeTooltip extends Component {
/**
* Write the time to the tooltip DOM element.
*
* @param {String} content
* @param {string} content
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess the linter fixed this one.

style.width = percentage;
const sizeKey = this.vertical() ? 'height' : 'width';

if (style[sizeKey] !== percentage) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only update on change, prevents a style recalculate

const bound = function() {
return fn.apply(context, arguments);
};
const bound = fn.bind(context);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use the native bind function

Copy link
Member

Choose a reason for hiding this comment

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

ooh, this likely will be super helpful in debugging.

Copy link
Member

Choose a reason for hiding this comment

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

Yup, it removes an extra stack frame. Goes from data dispatcher directly to the method instead of through this bound method.

@gkatsev
Copy link
Member

gkatsev commented Jul 29, 2019

Unfortunately, I don't think we can accept a large chunk of these changes as is. While a user is inactive, they could have still used their screen reader to focus on the seekbar or the time tooltip and would expect it to continue updating during playback. We probably want to do this for document visibility instead of user activity in the player.

@brandonocasey brandonocasey changed the title perf: timers, raf, and bind perf: throttle more timers and use native bind Jul 30, 2019
*/
constructor(player, options) {
super(player, options);
this.update = Fn.throttle(Fn.bind(this, this.update), 25);
Copy link
Member

Choose a reason for hiding this comment

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

in the seek bar, we throttle to 30ms: https://github.com/videojs/video.js/blob/master/src/js/control-bar/progress-control/seek-bar.js#L25, probably worth using the same thing everywhere. Maybe even have this value as a property exported from Fn utils?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah let's do that.

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.

2 participants