collab-project / videojs-record

video.js plugin for recording audio/video/image files
https://collab-project.github.io/videojs-record
MIT License
1.4k stars 315 forks source link

Destroy FFMPEG WASM workers when the dispose lifecycle event happens #736

Open nicolo-kira opened 1 week ago

nicolo-kira commented 1 week ago

In our local application we noticed that if you run the ffmpeg-wasm convert engine multiple times in a row, even after calling the VideoJS dispose function, the plugin loads the ffmpeg workers into the browser on every conversion. This caused a memory leak and eventual crash in our application, as the number of workers trying to run kept growing and growing

I've added a dispose hook in the convert engine similar to the record engine, which would be called when the player is disposed of, and cleans up the ffmpeg workers to avoid the memory leak.

coveralls commented 1 week ago

Coverage Status

coverage: 71.353% (-0.09%) from 71.445% when pulling b5d97e464d343adb7434d0f89c7b7d325bf7ea49 on kira:fix-ffmpeg-wasm-leak into 1285cec84cb3e8b7d8f71e51087acfc08d356fc2 on collab-project:master.