Skip to content

Conversation

@dsdolzhenko
Copy link
Contributor

@dsdolzhenko dsdolzhenko commented May 12, 2022

In the PR, besides fixing the bug described in #818, I also replaced the if condition with an assert as the code under it is not supposed to be executed anyway. Moreover, the assertion allows to catch the bug by running the unit test for RTC::RateCalculator

`RemoveOldData` is supposed to remove old buffer items
It fixes the case when `nowMs` equals `oldestItemStartTime` + `windowSizeMs`.
@dsdolzhenko dsdolzhenko requested a review from ibc May 12, 2022 15:41
@ibc
Copy link
Member

ibc commented May 12, 2022

@jmillan ?

@dsdolzhenko dsdolzhenko requested a review from jmillan May 17, 2022 14:02
@ibc ibc merged commit 542db78 into versatica:v3 May 25, 2022
@dsdolzhenko dsdolzhenko deleted the dsdolzhenko/rtc-rate-calculator branch May 25, 2022 12:07
@gnauhtt
Copy link
Contributor

gnauhtt commented May 28, 2022

Something wrong in this PR, will stuck in an infinite loop when 'this->oldestItemStartTime == newOldestTime'.

while (this->oldestItemStartTime <= newOldestTime)
{
	BufferItem& oldestItem = this->buffer[this->oldestItemIndex];
	this->totalCount -= oldestItem.count;
	oldestItem.count = 0u;
	oldestItem.time  = 0u;

	if (++this->oldestItemIndex >= this->windowItems)
		this->oldestItemIndex = 0;

	const BufferItem& newOldestItem = this->buffer[this->oldestItemIndex];
	this->oldestItemStartTime       = newOldestItem.time;
}

@ibc
Copy link
Member

ibc commented May 28, 2022

Can you detail where/why the infinite loop would happen?

@jmillan
Copy link
Member

jmillan commented May 28, 2022

PR reverted until the issue is clarified.

jmillan added a commit that referenced this pull request May 28, 2022
This reverts commit 542db78.

Infinite loop detected. Reverted until fixed.
@gnauhtt
Copy link
Contributor

gnauhtt commented May 29, 2022

Create a PlainTransport to receive data from ffmpeg. At this point the plainTransport sends an rtcp packet every second. And 'sendTransmission' 's windowSizeMs are also one second. When the program runs to ‘RateCalculator::RemoveOldData()’, When 'this->oldestItemStartTime == newOldestTime' happens at the same time as 'just one BufferItem in the RateCalculator::buffer'. It will remove this last BufferItem, so 'this->oldestItemStartTime' will set to 0. So that (this->oldestItemStartTime <= newOldestTime) ==> (0 <= newOldestTime) always true.

@ibc
Copy link
Member

ibc commented May 30, 2022

Thanks. The commit has been reverted. In fact I found our demo server with the worker process in an infinite loop. Thanks.

@dsdolzhenko
Copy link
Contributor Author

Oh. @rtctt thank you for reporting that. I'll prepare a new PR with proper fix and unit test later this week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants