meetecho / janus-gateway

Janus WebRTC Server
https://janus.conf.meetecho.com
GNU General Public License v3.0
8.25k stars 2.48k forks source link

Remove old tracks before adding/replacing new ones in janus.js #3203

Closed lminiero closed 1 year ago

lminiero commented 1 year ago

When we implemented #3003 in janus.js, we made it so when adding/replacing new tracks, we'd first capture the new track and only after that we'd remove the old one: actually, when doing replace: true, the previous track would not be removed at all. Apparently this caused problems on some devices, e.g., as reported in #3201.

This patch tries to address that, by removing a track before it's updated. We had a FIXME in there since this may cause problems, as with this change there could be some time in between a track is removed and then replaced when nothing is added. As such, I'm providing this as a PR: please test and ensure it doesn't cause regressions or problems, as I plan to merge soon if it fixes the problem.

rjnpnfigueiredo commented 1 year ago

With this code change Android has the correct behavior and has not introduced any issues on other platforms as far as I can test.

lminiero commented 1 year ago

Ack, merging then :+1: