Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Memory leak in sample-player (includes fix/PR) #102

Open
sschmidTU opened this issue Sep 6, 2022 · 0 comments
Open

Memory leak in sample-player (includes fix/PR) #102

sschmidTU opened this issue Sep 6, 2022 · 0 comments

Comments

@sschmidTU
Copy link

sschmidTU commented Sep 6, 2022

Used memory increases the longer samples are played in one session. You'll see a lot of GainNode objects piling up.
For those interested, I shared our fix here:
danigb/sample-player#8

In our library (OpenSheetMusicDisplay, early access audio player), we patch this fix into node_modules/sample-player, otherwise we'd have to wait for a new release of sample-player and soundfont-player.

You can do this hotfix like this:
Add this in package.json under scripts:

{
  "prebuild": prebuildSamplePlayer,
  "prebuildSamplePlayer": "ncp src/SamplePlayerPatch/lib/ node_modules/sample-player/lib/",
}

prebuild is automatically executed with npm run build.
(you can just put the bottom line into prebuild if you don't have other prebuild scripts, otherwise use npm-run-all in prebuild)
(of course you need to put the patched .js files into src/SamplePlayerPatch/lib/)


Dependencies:
ncp is a dependency you'll need to add:
"ncp": "^2.0.0",

This is just cp (a copy command) that works on Mac, Linux and Windows. I'm not aware of another easy platform-agnostic way to do that. And it's 17.5KB.

Also npm-run-all, if you want to use it in prebuild:
"npm-run-all": "^4.1.5",
->
prebuild: npm-run-all myPrebuild prebuildSamplePlayer

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant