Memory leak in browser on screenshare

Hi Livekit team,

I found a memory leak in the RTC engine of Livekit that causes memory consumption in the browser to grow if you publish / unpublish screen shares in a loop under some special circumstances ( stopOnUnpublish: false )

This is easily reproducible in “meet.livekit.io” (simply start a meeting and start/stop screen sharing in a loop to see the memory leak).

I have a proposal to fix this in a PR here: Reuse inactive publisher transceivers in RTCEngine to reduce memory growth on republish by moufmouf · Pull Request #1827 · livekit/client-sdk-js · GitHub

I know you must have a ton of work already, but I wanted to give this PR a chance to be properly reviewed, as it would probably save some RAM to many users.

Thanks a lot for your hard work!

Thanks David, I have raised this with the client team to see if they can take a look.