cifkao / html-midi-player

🎹 Play and display MIDI files on the web
https://cifkao.github.io/html-midi-player/
BSD 2-Clause "Simplified" License
630 stars 56 forks source link

Are the Magenta lib and Sound Banks loaded for each instance of the player? #59

Closed lautarodragan closed 1 year ago

lautarodragan commented 1 year ago

Hey there! First of all I want to say this is an awesome project. Thank you so much for building it and making it available for everyone.

Regarding my question: I've placed about 20 <midi-player sound-font>'s in my page, and the Memory footprint (as show by Google Chrome's Task Manager) grew to over 2.5gb! Event over 4.8gb at times (seems pretty random). And the page usually hangs indefinitely, too. I need to kill the tab from the Task Manager.

If I use no sound-font, it's only ~67mb. Without loading this script at all, it's ~46mb.

The RAM footprint seems to be related to the amount of instances. Some numbers

I could dynamically add and remove instances of the elements to limit the memory footprint, but UI and UX would suffer. Is there a way to globally load this library's dependencies, once for all instances?