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

Player init is very slow (~3s) in Firefox if there are a lot of variant tracks #4775

Closed
Dador opened this issue Dec 1, 2022 · 6 comments
Closed
Assignees
Labels
browser: Firefox Issues affecting Firefox or Gecko derivatives priority: P2 Smaller impact or easy workaround status: archived Archived and locked; will not be updated type: enhancement New feature or request
Milestone

Comments

@Dador
Copy link
Contributor

Dador commented Dec 1, 2022

Have you read the FAQ and checked for duplicate open issues?
Yes.

What version of Shaka Player are you using?
nightly (795342d)

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 107.0.1 (x86_64-apple-darwin)

What are the manifest and license server URIs?

What configuration are you using? What is the output of player.getConfiguration()?
Defaults from demo app.

What did you do?
Open video with a lot of variant tracks. In my case it's video with 120 variant tracks (30 audio languages * 4 resolutions = 120 variant tracks).

What did you expect to happen?
Video is playable without big delays.

What actually happened?
In Firefox there is big additional delay (around 3 seconds) before video is playable.

My thoughts
Seems like mcap is a bit slow in Firefox and it's called for each variant track (120 times in my case), so takes a lot of time (around 3 seconds in my case).
There is no issue in Chrome as mcap there seems to be very fast.
Gist to compare Firefox and Chrome: https://gist.github.com/Dador/1861acefcabf083e7238031f224bebc6

Issue #4574 and recent PR #4708 are related, but mcap polyfill is not enabled in Firefox. Enabling it for Firefox solves the performance issue but I guess that's a dirty way to solve it?

Maybe some caching could be added (or moved from mcap polyfill) to mediaCapabilities.decodingInfo usage in stream_utils.js?

@Dador Dador added the type: bug Something isn't working correctly label Dec 1, 2022
@github-actions github-actions bot added this to the v4.4 milestone Dec 1, 2022
@theodab theodab added browser: Firefox Issues affecting Firefox or Gecko derivatives priority: P2 Smaller impact or easy workaround labels Dec 5, 2022
@theodab
Copy link
Contributor

theodab commented Dec 5, 2022

This sounds like a reasonable idea to me.

@theodab theodab self-assigned this Dec 5, 2022
@theodab theodab added type: enhancement New feature or request and removed type: bug Something isn't working correctly labels Dec 5, 2022
theodab added a commit to theodab/shaka-player that referenced this issue Dec 5, 2022
theodab added a commit to theodab/shaka-player that referenced this issue Dec 5, 2022
@theodab
Copy link
Contributor

theodab commented Dec 6, 2022

I'll leave this open for now because you didn't provide a sample asset, so I can't verify how much the PR helped. If you test this yourself and find the startup time is good now, feel free to close this issue yourself, thanks.

@Dador
Copy link
Contributor Author

Dador commented Dec 7, 2022

Thank you.

I sent sample URL to email (shaka-player-issues).

Looks like PR didn't helped in my case. There are no cache HITs, log: https://gist.github.com/Dador/c0a3a6bf90f4dcad62c898529671f079 (I added logging for HIT/MISS)
In total it checked mcap 240 times (30 audios * 4 resolutions * 2 DRM options)

I have 30 audios and each audio have slightly different bitrate (you can see it in log), so decodingConfig is unique for each variant track. Cache key in polyfill is more simple, so that's why caching there helped (with forcefully enabled polyfill for Firefox, it checks mcap around 4 times).

@theodab
Copy link
Contributor

theodab commented Dec 7, 2022

I see.
I had considered adding some rounding to the bitrate before turning the config into a cache key, to increase the chance of a cache hit, but I was worried that it would lead to false cache hits. I don't think that making the key any vaguer would be a good idea.

Thinking about it, though, there's another possible optimization.
Looking at the code, most of the results of mediaCapabilities.decodingInfo are only used if the preferredDecodingAttributes configuration value is given one or more preferences. If that configuration value is left as an empty array, it looks like the only parts of decoding info we need are supported and keySystemAccess.keySystem (for DRM content). Those are both values that we don't strictly need to call the real mediaCapabilities.decodingInfo to know.

So maybe we could only call mediaCapabilities.decodingInfo if preferredDecodingAttributes is non-empty.

@avelad
Copy link
Member

avelad commented Feb 3, 2023

@Dador Can you test with main branch? Thanks!

@avelad avelad added the status: waiting on response Waiting on a response from the reporter(s) of the issue label Feb 3, 2023
@github-actions
Copy link
Contributor

Closing due to inactivity. If this is still an issue for you or if you have further questions, the OP can ask shaka-bot to reopen it by including @shaka-bot reopen in a comment.

@github-actions github-actions bot removed the status: waiting on response Waiting on a response from the reporter(s) of the issue label Feb 10, 2023
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Apr 11, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
browser: Firefox Issues affecting Firefox or Gecko derivatives priority: P2 Smaller impact or easy workaround status: archived Archived and locked; will not be updated type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants