Player.addThumbnailsTrack()
is slow and freezes the browser for long videos
#6065
Labels
priority: P1
Big impact or workaround impractical; resolve before feature release
status: archived
Archived and locked; will not be updated
type: bug
Something isn't working correctly
Milestone
Have you read the FAQ and checked for duplicate open issues?
Yes
If the problem is related to FairPlay, have you read the tutorial?
Not applicable
What version of Shaka Player are you using?
4.7.3
Can you reproduce the issue with our latest release version?
Yes
Can you reproduce the issue with the latest code from
main
?Yes
Are you using the demo app or your own custom app?
Both
If custom app, can you reproduce the issue using our demo app?
Yes
What browser and OS are you using?
Firefox on Windows 10
For embedded devices (smart TVs, etc.), what model and firmware version are you using?
Not applicable
What are the manifest and license server URIs?
Here is a 10 hour long vtt file, it's long enough to noticably reproduce the issue, but short enough that the browser eventually recovers from being frozen.
GitHub doesn't allow the
.vtt
file extension, so I had to rename it to.txt
before uploading.long-thumbnails.txt
What configuration are you using? What is the output of
player.getConfiguration()
?Default
What did you do?
await document.getElementById('video').ui.getControls().getPlayer().addThumbnailsTrack(
data:text/vtt;charset=utf-8,${encodeURIComponent(contents of file here)}, 'text/vtt')
What did you expect to happen?
The thumbnails to be added quickly and the browser to not freeze.
What actually happened?
The web browser froze for a while, although it did eventually recover.
Clicking on the dropdowns is one good way to notice that the page is frozen.
Doing a performance benchmark while it was frozen (starting it before adding the thumbnails and stopping it when the web browser recovers), showed that in total the majority of time was spent in
shaka.util.ManifestParserUtils.resolveUris
, whichaddThumbnailsTrack
calls in a for loop.shaka-player/lib/player.js
Lines 4839 to 4842 in 1b7a54c
shaka.util.ManifestParserUtils.resolveUris
has a note the indicates that it is a known performance bottleneck.shaka-player/lib/util/manifest_parser_utils.js
Lines 21 to 22 in 1b7a54c
As
addThumbnailsTrack
is calling it in a loop, that means it creates two newgoog.Uri
objects every time, one for the base URI (which doesn't change) and one for the thumbnail URI and then resolves the thumbnail URI against the base URI. One minor change that would probably make a major difference is creating the base URIgoog.Uri
object once and then reusing it, instead of creating a new one for each iteration. Here is a small example of how that could be done:As mentioned in a previous issue, I would happily create pull requests, if the CLA didn't exist. Having to doxx myself to contribute to a project is unfortunately a big turn off, I know that other people feel the same way too.
The text was updated successfully, but these errors were encountered: