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: don't throttle duration change updates #4635
Conversation
802bee0
to
f51d36b
Compare
33f5a21
to
a49eb16
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, though, there's a test failing.
b31b49d
to
44ab963
Compare
@@ -48,7 +48,7 @@ class TimeDisplay extends Component { | |||
'aria-live': 'off' | |||
}, Dom.createEl('span', { | |||
className: 'vjs-control-text', | |||
textContent: this.localize(this.contentText_) | |||
textContent: this.localize(this.controlText_) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a typo, I could arguable pull this into its own pr if we want, but this is one of the causes of the broken unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what's causing the issue on ie8? https://travis-ci.org/videojs/video.js/jobs/290639178#L1937-L1941
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im actually not sure what is causing the failure on IE8, this must have just fixed IE9
@@ -63,7 +63,7 @@ class TimeDisplay extends Component { | |||
* @private | |||
*/ | |||
updateTextNode_() { | |||
if (this.textNode_) { | |||
if (this.textNode_ && this.contentEl_ && this.contentEl_.contains(this.textNode_)) { | |||
this.contentEl_.removeChild(this.textNode_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IE11 throws in request animation frames when trying to remove a DOM node from a container when the container does not have the node. Might only be an issue for our unit tests, but I fixed it here.
44ab963
to
af4cf3f
Compare
0d7f7f7
to
b19efc5
Compare
const disposeFn = function() { | ||
this.clearTimeout(timeoutId); | ||
}; | ||
const disposeFn = () => this.clearTimeout(timeoutId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemed a bit weird to me in a regular function we wouldn't have access to this.clearTimeout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we call the dispose
handler with context as the component instance, so, it should have it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at least, it should be. this is ok too.
cc27517
to
835f720
Compare
const disposeFn = function() { | ||
this.clearInterval(intervalId); | ||
}; | ||
const disposeFn = () => this.clearInterval(intervalId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed here as well
const disposeFn = function() { | ||
this.clearTimeout(timeoutId); | ||
}; | ||
const disposeFn = () => this.clearTimeout(timeoutId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we call the dispose
handler with context as the component instance, so, it should have it.
const disposeFn = function() { | ||
this.clearTimeout(timeoutId); | ||
}; | ||
const disposeFn = () => this.clearTimeout(timeoutId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at least, it should be. this is ok too.
return; | ||
} | ||
|
||
// ie8/9 don't support `el.contains` inside of setTimeout call. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird
} | ||
|
||
// ie8/9 don't support `el.contains` inside of setTimeout call. | ||
if (this.textNode_ && this.textNode_.parentNode === this.contentEl_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about just removing everything inside of contentEl_
? It'll also fix an issue where if the page is translated in chrome using google translate, the text node will be wrapped in another element and this method will fail.
This could also just happen in a separate PR.
@@ -1239,9 +1239,7 @@ class Component { | |||
fn = Fn.bind(this, fn); | |||
|
|||
const timeoutId = window.setTimeout(fn, timeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I almost commented saying that this should be changed to this.setTimeout
before realizing what this line is for 😆
Description
Right now the
durationchange
event is throttled with the other two events,timeupdate
andloadedmetadata
. This means that only one of those events will trigger an update if they all occur within 25ms of each other.This functionality makes sense for
timeupdate
orloadedmetadata
as those should not indicate a time update (even though they often do).For
durationchange
however it will always indicate a change in the duration, and we want to always update the display when it happens. Here is a scenario of how we could show duration incorrectly right now:User is playing a video that has a postroll ad at the end. After the postroll ad their will be a
timeupdate
, and then adurationchange
to signify that we are back in content. Thenended
will fire, and no more events will happen.The player will still show the duration of the ad, as the
durationchange
was eaten by thetimeupdate
that happened at nearly the same time.Requirements Checklist