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: Caching mediaSource support for browser engine #4778

Merged
merged 5 commits into from
Dec 6, 2022
Merged

perf: Caching mediaSource support for browser engine #4778

merged 5 commits into from
Dec 6, 2022

Conversation

BrainChen
Copy link
Contributor

We have just derived the repository by the old shaka version and found there seems the same optimization could be implemented on the latest shaka player.

When developing on each web core livingroom platform (Tizen, WebOS, Chromecast, etc.), we found that there takes a long time to parse the manifest between downloading the manifest and downloading the first content segment. After profiling it, we found that there was a frequent function called MediaSource.isTypeSupported in it, up to hundreds or even thousands (the pic attached below). But this situation does not happen on the latest Chrome or Safari.

image

We concluded that it must be related to the old browser engine (Chromium) that does not do optimization on it.

And we just cached the function call results and let it not calls that API so frequently. The data showed that it did help reduce the start lag by 40% on Chromecast, 15% on WebOS, and 12% on Tizen on average within 2 months.

We think it is constructive and want to share it. And we think the more variants the contents have, the more time they could be reduced on living room apps.

Thanks!

@avelad avelad added type: performance A performance issue priority: P1 Big impact or workaround impractical; resolve before feature release labels Dec 2, 2022
@avelad avelad added this to the v4.4 milestone Dec 2, 2022
@avelad
Copy link
Member

avelad commented Dec 2, 2022

@JulianDomingo, can you test if on chromecast we have this gain?

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2022

Incremental code coverage: 97.56%

@BrainChen BrainChen requested review from theodab and removed request for joeyparrish, avelad and JulianDomingo December 3, 2022 03:15
avelad
avelad previously approved these changes Dec 3, 2022
@avelad
Copy link
Member

avelad commented Dec 5, 2022

@BrainChen You can apply the shaka.media.MediaSourceEngine.isTypeSupported change to media/transmuxer.js and polyfill/media_capabilities.js?. Thanks!

@BrainChen
Copy link
Contributor Author

@avelad There seems exists cyclic dependencies when I implemented it in media/transmuxer.js. Hence extract this function into a single file.

@BrainChen
Copy link
Contributor Author

@avelad Emmm, I think the change on polyfill/media_capabilities.js could possibly be conflicted with the unit test as some media types may be cached before and never called again.

@BrainChen BrainChen requested review from avelad and theodab and removed request for theodab and avelad December 5, 2022 13:23
@BrainChen
Copy link
Contributor Author

@avelad Sorry for not obeying the precheck.
But I get puzzled that there is a difference between local build and CI build,
As I face StreamingEngine VOD plays FAILED, SegmentIndex MetaSegmentIndex updates through updateEvery FAILED, TextDisplayer layout using UI line alignment FAILED on my local laptop while the CI was not.

@theodab theodab merged commit ad6c085 into shaka-project:main Dec 6, 2022
@theodab
Copy link
Contributor

theodab commented Dec 6, 2022

Thank you for your contribution!

@vasanth-fl
Copy link

vasanth-fl commented Dec 6, 2022

@theodab @avelad @joeyparrish Will this change be cherry-picked to 3.2.16 as well? We would love to have this optimisation available on CAF v3 receiver to improve video start time on Chromecast.

@joeyparrish
Copy link
Member

If it cherry-picks cleanly, then yes, I will cherry-pick this to v3.2.x as well as all the other active branches. If not, I'll let you know and you can make a PR against v3.2.x to get it into the next v3.2 release.

@BrainChen
Copy link
Contributor Author

BrainChen commented Dec 7, 2022

@vasanth-fl Be aware that some of the old shaka versions, EXTENDED_MIME_PARAMETERS, which is depreciated from the latest one, also work. That could also occupy much call time along with many combinations. We just retained the codecs and removed frameRate, channelsCount, etc. These parameters seem useless on Chromium and some browser engines as they are not the W3C standard.
See more details on:

joeyparrish pushed a commit that referenced this pull request Dec 8, 2022
Caches the results of MediaSource.isTypeSupported, which is slow on some platforms, to reduce the
number of calls needed. This is especially helpful on manifests with many similar variants (multiple languages, etc).
Data collected from 2 months of practical testing shows that this helps reduce the start lag by 40% on Chromecast, 15% on WebOS, and 12% on Tizen.
@joeyparrish
Copy link
Member

This did not cherry-pick cleanly to older branches. It was released in v4.3.1 only.

@vasanth-fl
Copy link

@BrainChen thanks for the inputs!

@joeyparrish thanks for the note. We will try to analyse and try to make a PR against 3.2.x branch.

@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: P1 Big impact or workaround impractical; resolve before feature release status: archived Archived and locked; will not be updated type: performance A performance issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants