From 044eaec509615727514831376e5e8cdf55d97a32 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sat, 19 Sep 2020 02:31:46 +0100 Subject: [PATCH 1/3] Update Wavesurfer to fix Ram Leak on .destroy() --- package.json | 4 ++-- yarn.lock | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 81aa578..7c148ec 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "@types/reactstrap": "^8.4.2", "@types/redux-persist": "^4.3.1", "@types/sdp-transform": "^2.4.3", - "@types/wavesurfer.js": "^3.2.0", + "@types/wavesurfer.js": "^3.3.1", "@types/webpack-env": "^1.14.1", "@typescript-eslint/eslint-plugin": "^2.2.0", "@typescript-eslint/parser": "^2.2.0", @@ -99,7 +99,7 @@ "ts-pnp": "1.1.4", "typescript": "3.7.2", "url-loader": "2.1.0", - "wavesurfer.js": "3.3.3", + "wavesurfer.js": "4.0.1", "webpack": "4.41.0", "webpack-dev-server": "3.2.1", "webpack-manifest-plugin": "2.1.1", diff --git a/yarn.lock b/yarn.lock index 8b8748c..312db1e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1688,10 +1688,10 @@ resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw== -"@types/wavesurfer.js@^3.2.0": - version "3.3.0" - resolved "https://registry.yarnpkg.com/@types/wavesurfer.js/-/wavesurfer.js-3.3.0.tgz#79b22405a305cac1acfc19d648574d032b16ca92" - integrity sha512-OqxmEUl2CP1G5tl1jj1huzo/38FiWpDyS1woI/Hu6S9wsLJ2ihcimAAjdQlwNtXDl2CjVBDl4dVoHN8XTX8eSQ== +"@types/wavesurfer.js@^3.3.1": + version "3.3.1" + resolved "https://registry.yarnpkg.com/@types/wavesurfer.js/-/wavesurfer.js-3.3.1.tgz#e276ca371b382072b894b57a166c5f6ecdfb4964" + integrity sha512-TpWT5eW57ZyhH7uOlHBAnQ+kpp5f+lyjaoGSYk5q447U9ulIOm5eUURiYBIZUlIZqrL0Levaniq8flnug0ir0w== "@types/webpack-env@^1.14.1": version "1.15.2" @@ -11119,10 +11119,10 @@ watchpack@^1.6.0: chokidar "^3.4.0" watchpack-chokidar2 "^2.0.0" -wavesurfer.js@3.3.3: - version "3.3.3" - resolved "https://registry.yarnpkg.com/wavesurfer.js/-/wavesurfer.js-3.3.3.tgz#9b16a62335c6bd13a3d55deb895a336d027ccb51" - integrity sha512-meko20S9in+V5xBLSVV/9uYVBSbx5AsJNkAslZ+a5yYIeFGYwcCo4Yd1sUpSGaiNnyflzrJwC7x7TdJFYrdT8w== +wavesurfer.js@4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/wavesurfer.js/-/wavesurfer.js-4.0.1.tgz#392502f4956fc96cff9dbb0fccdc9debfaed4e97" + integrity sha512-MvFVjxGVstYZqRI/BzkGupRuB1S7MtQClWPqgjTBTg+2ssxUAJlOGFhZsrtxDvCocneuWXqZ0g+sm/8OGl7X1w== wbuf@^1.1.0, wbuf@^1.7.3: version "1.7.3" From 55ca3bd0a588e761f05ee6ebbcc759d9bd892e36 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sat, 19 Sep 2020 02:44:46 +0100 Subject: [PATCH 2/3] I think we're supposed to unsub from events too. --- src/mixer/audio.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mixer/audio.ts b/src/mixer/audio.ts index df0615f..30986d0 100644 --- a/src/mixer/audio.ts +++ b/src/mixer/audio.ts @@ -151,6 +151,8 @@ class Player extends ((PlayerEmitter as unknown) as { new (): EventEmitter }) { } cleanup() { + // Unsubscribe from events. + this.wavesurfer.unAll(); // Let wavesurfer remove the old media, otherwise ram leak! this.wavesurfer.destroy(); } From 43fd12904ffce90fab44a39ac8f83b8a9d74147e Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sat, 19 Sep 2020 02:55:53 +0100 Subject: [PATCH 3/3] Apparently sometimes the buffer still doesn't cleanup. --- src/mixer/audio.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mixer/audio.ts b/src/mixer/audio.ts index 30986d0..6afefb3 100644 --- a/src/mixer/audio.ts +++ b/src/mixer/audio.ts @@ -154,6 +154,8 @@ class Player extends ((PlayerEmitter as unknown) as { new (): EventEmitter }) { // Unsubscribe from events. this.wavesurfer.unAll(); // Let wavesurfer remove the old media, otherwise ram leak! + // See https://github.com/katspaugh/wavesurfer.js/issues/1940. + delete (this.wavesurfer as any).backend.buffer; this.wavesurfer.destroy(); } }