shaka-project / shaka-player

JavaScript player library / DASH & HLS client / MSE-EME player
Apache License 2.0
6.93k stars 1.31k forks source link

Memory leak on multi-period streams #6239

Open bbert opened 4 months ago

bbert commented 4 months ago

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

If the problem is related to FairPlay, have you read the tutorial?

Yes

What version of Shaka Player are you using?

4.2.x => 4.7.x

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? Demo app

If custom app, can you reproduce the issue using our demo app? Yes

What browser and OS are you using? chrome, windows

For embedded devices (smart TVs, etc.), what model and firmware version are you using?

What are the manifest and license server URIs?

https://d24rwxnt7vw9qb.cloudfront.net/v1/dash/e6d234965645b411ad572802b6c9d5a10799c9c1/All_Reference_Streams/4577dca5f8a44756875ab5cc913cd1f1/index.mpd

What configuration are you using? What is the output of player.getConfiguration()?

Default

What did you do?

Play stream and take memory heap snapshots using chrome dev tools at different times

What did you expect to happen? Memory heap to be stable

What actually happened?

Memory heap grows consistently for multi-period streams. On mono-period streams, we dot not notice the same result.

Please find screenshots:

Please note that all objects (Text, Element, NodeList ...) are allocated in the same place.

avelad commented 4 months ago

Duplicate of https://github.com/shaka-project/shaka-player/issues/6070

bbert commented 4 months ago

I'm not sure this is a duplicate of #6070 since #6070 memory issue is related to SegmentTimeline and the one described in this issue is more generally related to multi-periods, and noticeably since at least v 4.2.x.

joeyparrish commented 4 months ago

Reopening.

avelad commented 1 month ago

@bbert Can you test if it still happens with 4.8.3? Thanks!

bbert commented 1 month ago

@avelad Have you tested on your side? I still observe memory increase: image

avelad commented 1 month ago

We solved a memory leak, but I didn't know if it had solved all your problems or not.

bbert commented 1 month ago

My asumption is that memory consumption should not constantly increase in any case. After a quick check, the issue still remains for SegmentTimeline based multi-period streams.

avelad commented 1 month ago

Do you want send a PR to fix it?

bbert commented 1 month ago

For the time being, I'm not enough aware of source code to try to fix it in the shot term.

It seems indeed that the initial reason of the identified memory leak has been fixed (as discussed in #6070), but here is a potential clue to identify the leak:

image

MichaelSweden commented 1 month ago

I have tested the stream in this issue with Cobalt browser with a simple html page and default shaka config. Using main branch (12 May, last commit 5f8628a4a). I can confirm growing memory usage. Also tested in Chromium (124.0.6367.155, Xubuntu 22.04) and see these JS heap size: 5 min : 12-16 MB 1 hour : 83-91 MB 2 hours : 174-179 MB 3 hours : 257-263 MB

PS. We have a similar problem with another dash live stream and I have a fix for it. However that fix doesn't solve this issue.