Skip to content

Performance issues while parsing / playing large DASH playlistsΒ #9154

@Robertof

Description

@Robertof

I am using video.js (latest, 8.23.4) on Firefox 148 with a large DASH playlist (30 period tags, 180 adaptation sets/segment templates) and it struggles a lot. I profiled it during the fact and noticed that it was spending inordinate amounts of time on calls to resolveUrl:

Image

In particular, it seems that for my playlist each call to refreshMedia_() triggers about 88200 (!) calls to resolveUrl() from vhs-utils. All of the time is spent in the URL() constructor which is apparently fairly expensive when called 80k times. When refreshMedia_() is called every 500ms, the browser can't parse the URLs fast enough and it hinders playback.

For fun I replaced the logic in resolveUrl() with a very primitive:

    baseUrl = baseUrl.replace(/\?.+$/, '');
    baseUrl = baseUrl.replace(/\/[^\/]+$/, '');
    return baseUrl + "/" + relativeUrl;

and suddenly all the performance issues are gone!

I also tried to cache the result of parseMainXml, and while it does manage to make playback good enough, the UI still lags while the thousands of URLs are being parsed.

I am unable to share a link to a reproducer / the stream URL as it is confidential, but here's how a slightly redacted version of the main playlist looks like:

main-redacted.mpd.xml

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions