matrix-org / waterfall

A cascading stream forwarding unit for scalable, distributed voice and video conferencing over Matrix
Apache License 2.0
97 stars 5 forks source link

track: fix incorrect subscription existence check #149

Closed daniel-abramov closed 1 year ago

daniel-abramov commented 1 year ago

If someone tries to subscribe to an audio or non-simulcast track and the subscription exists already, we must not create a new subscription.

The implementation in main had a bug where each client entered a vicious cycle of adding a subscription -> getting the renegotiation from Pion -> sending it to the remote counterpart of the client -> adding a new track -> subscribing again -> again getting the renegotiation from Pion -> ... etc.

The only thing that is not quite clear is why the client tried to subscribe to the same track many times. Regardless of this, the SFU should not have created new subscriptions for the subscriptions that already exist, this PR fixes that.