shaka-project / shaka-player

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

Excessive memory usage for DASH live with EventStream nodes #7148

Closed willdharris closed 4 days ago

willdharris commented 1 month ago

Have you read the FAQ and checked for duplicate open issues? Yes. These issues are related, but the fix added in v4.10.6 does not resolve this case. https://github.com/shaka-project/shaka-player/issues/6070 https://github.com/shaka-project/shaka-player/issues/6610

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

n/a

What version of Shaka Player are you using?

4.10.9

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? custom

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

What browser and OS are you using? Chrome Version 127.0.6533.100 (Official Build) (arm64) macOS Ventura v13.6

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

What are the manifest and license server URIs?

Can provide private stream via email if needed. Issue is not as pronounced but is reproducible with this public stream: https://refapp.hbbtv.org/videos/multiperiod_v8.php?drm=0&advert=1&emsg=0&video=v1,v2,v3&audiolang=eng,fin&sublang=eng,fin,swe&mup=2&spd=8.

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

Only change from default is manifest.dash.disableXlinkProcessing = true.

What did you do?

Load a Live DASH manifest with a 3hr DVR window (timeShiftBufferDepth="PT3H0M0S") that includes EventStream nodes in the manifest.

What did you expect to happen? I expect to see JS Memory usage and GC more in line with earlier versions of Shaka.

What actually happened?

JS Memory grows at a much faster pace in v4.10.9 than in previous versions tested (v4.3.6 and v4.7.15).

Chrome Desktop - DASH LTS - JS Memory               
Time    v4.3.6  v4.7.15 v4.10.9 
30min   58MB    30MB    225MB   
60min   76MB    49MB    428MB   
90min   93MB    64MB    548MB   

task-manager-shaka-90min copy

Are you planning send a PR to fix it? No. We can currently work around this issue by removing EvenStream nodes from our manifests and use InbandEventStream emsg instead. Note the memory improvements when EvenStream nodes are filtered from the manifest.

Chrome Desktop - DASH LTS - JS Memory - EventStream Filter              
Time    v4.3.6  v4.7.15 v4.10.9 v4.10.9 w/ Filter
30min   47MB    37MB    136MB   23MB
60min   58MB    52MB    258MB   39MB
eventstream-filter

Here is more detail on what may be contributing.

Our 3 hr DVR manifest includes 50+ EventStream nodes with combined thousands of child Event nodes. In v4.10.9, Memory heap snapshots are showing thousands of Detached HTMLUnknownElements, which do not appear in v4.3 or v4.7. detached-unknown-shaka-4 10 9

These elements appear to come from parseEventStream_ when elements are created with txmlNodeToDomElement.

parseeventstream-shaka

txmltodom-shaka

Iragne commented 3 weeks ago

I'm working on a this too and I will share shortly my findings and possible pr. This look due also to a leaks I. Multi period manifest I'm still validating my findings