Volcomix / virtual-background

Demo on adding virtual background to a live video stream in the browser
https://volcomix.github.io/virtual-background
Apache License 2.0
488 stars 124 forks source link

Huge memory consumption (meet+WebGL2) #44

Open jibon57 opened 2 years ago

jibon57 commented 2 years ago

First of all thanks for excellent solution. I was checking the demo site as well my implementation in Plug-N-Meet. If I choose meet + WebGL2 in Firefox it use huge memory. If I continue using like almost 20~25 minutes, it used up 12GB+ of RAM & browser got crashed. With meet + Canvas 2D + CPU doesn't have this problem. Is this normal or is there any memory leaks somewhere?

HauHuu060988 commented 2 years ago

I guess the root cause is from https://github.com/Volcomix/virtual-background/blob/2adb3a95bcee4c42509c31ef1ecbb967ad9aa27f/src/pipelines/webgl2/webgl2Pipeline.ts#L164. I tried using ImageData instead of HTMLVideoElement, the problem did not occur but the quality is worse. I don't know if we have other solution to make sure this problem doesn't happen and keep good quality?