versatica / mediasoup

Cutting Edge WebRTC Video Conferencing
https://mediasoup.org
ISC License
6.26k stars 1.13k forks source link

Simulcast frozen video due to dropping RTP packets #1429

Closed quanli168 closed 3 months ago

quanli168 commented 3 months ago

Bug Report

We recently upgraded mediasoup from version 3.12.13 to 3.14.7 and noticed that video freezing has become more frequent since the upgrade. After enabling additional mediasoup logging, we believe this issue is due to a regression introduced in this pull request.

The problem occurs under the following conditions:

  1. The producer has two simulcast streams (SSRC-A and SSRC-B).
  2. The simulcast consumer is consuming SSRC-B.
  3. SSRC-A has a packet that contains only padding. Let's assume this packet's sequence number is SEQ-1. This packet is dropped and stored in the rtpSeqManager https://github.com/versatica/mediasoup/blob/06f66e62874ede5f4bb4a166ba2629280b9edada/worker/src/RTC/SimpleConsumer.cpp#L320
  4. SSRC-B then sends an RTP packet with the same sequence number. Since this sequence number is in rtpSeqManager's dropped list, it is assigned a sequence number of 0. https://github.com/versatica/mediasoup/blob/06f66e62874ede5f4bb4a166ba2629280b9edada/worker/src/RTC/SimpleConsumer.cpp#L394
  5. The packet is then dropped because its sequence number is 0 https://github.com/versatica/mediasoup/blob/06f66e62874ede5f4bb4a166ba2629280b9edada/worker/src/RTC/SimpleConsumer.cpp#L432

Attached are logs showing that RTP packets with sequence numbers 42015-42134 were dropped due to this scenario. exportedLogRecords.CSV

Your environment

Issue description

ibc commented 3 months ago

Thanks for the report. Will look soon.

ibc commented 3 months ago

The problem is that SimulcastConsumer::SendRtpPacket() method is dropping the packet and calling this->rtpSeqManager.Drop even if the packet doesn't below to the simulcast stream being sent to the consumer.

ibc commented 3 months ago

CC @ggarber

ibc commented 3 months ago

PR done here: https://github.com/versatica/mediasoup/pull/1431

Once merged, will release. Thanks a lot!