-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
move timeout back into parseCues #3181
Conversation
Going to see if I can add a test for this so it won't happen again :) |
@chemoish can you review this one? You probably know the most about how tracks load next to me. |
Does video.js have pub sub or anything we can leverage to listen to events? I would prefer…
Instead of having a Also, can't remember the influence of…
Also, should it be pointing to vtt.min.js? |
// Make sure that vttjs has loaded, otherwise, wait till it finished loading | ||
// NOTE: this is only used for the alt/video.novtt.js build | ||
if (typeof window.WebVTT !== 'function') { | ||
return window.setTimeout(function() { |
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.
If window.WebVTT
never loads, this is infinite loop?
script.src = this.options_['vtt.js'] || '../node_modules/videojs-vtt.js/dist/vtt.js';
still seems fragile (hence the question).
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.
Yes, it would. It should have a retry count, I guess.
Maybe changing it to send an event we can listen to is a better way of doing it, I'll see if I can do it quickly, I'd like to get this change in as quickly as possible.
@gkatsev since this is a patch I am ok with this going in and fixing it later to support retry or pubsub. I didn't step through the tests, but LGTM. |
return window.setTimeout(function() { | ||
parseCues(srcContent, track, retry); | ||
}, 100); | ||
} |
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.
Is 400ms enough time to wait? Is there any guarantee that will be enough time on slow connections or heavily loaded pages?
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'm not sure, I guess on really slow pages or really slow connections, it will die.
Maybe we want up to 10 retries?
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.
Add // TODO: listen to onload event or similar
(:
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 could also have it do incremental back-off, 100 for first, 200 for second, 400 for 3rd, 800 for second. Total would be 1.5s.
Assuming we don't just do the onload.
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.
@chemoish looks like it's not as urgent as other things, so, I'll spend time making it wait for vttjs to load instead of retrying :)
Updated the code to wait for the load event of the script and have loadTrack delay parseCues until such an event. What's left is to have those event handlers be removed if the script fails to load and also test updates. |
let offSpyCall = testTech.off.getCall(0); | ||
|
||
ok(errorSpyCall.calledWithMatch('vttjs failed to load, stopping trying to process'), | ||
'we logged the correct error after 3 timeouts'); |
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 message is outdated
Other than the update to the test message, LGTM |
Description
Make sure that vttjs has finished loading before proceeding with parsing cues.
Specific Changes proposed
Specifically, move the code that does a setTimeout from
loadTrack
back intoparseCues
. MakeparseCues
into an asynchronous loop waiting till vttjs has loaded.Requirements Checklist