Skip to content

Commit

Permalink
Fix overuse estimator crash (#1820)
Browse files Browse the repository at this point in the history
  • Loading branch information
lodoyun authored Jun 30, 2022
1 parent f221680 commit d7935de
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
5 changes: 4 additions & 1 deletion erizo/src/erizo/rtp/BandwidthEstimationHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ BandwidthEstimationHandler::BandwidthEstimationHandler(std::shared_ptr<RemoteBit
min_bitrate_bps_{kMinBitRateAllowed},
bitrate_{0}, last_send_bitrate_{0}, last_remb_time_{0},
running_{false}, active_{true}, initialized_{false} {
rtc::LogMessage::SetLogToStderr(false);
// Print RTC_LOG warnings and errors even in release builds.
rtc::LogMessage::ConfigureLogging("tstamp thread error");
rtc::LogMessage::LogToDebug(rtc::LS_ERROR);
rtc::LogMessage::SetLogToStderr(true);
}

void BandwidthEstimationHandler::enable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,14 @@ void OveruseEstimator::Update(int64_t t_delta,
bool positive_semi_definite =
E_[0][0] + E_[1][1] >= 0 &&
E_[0][0] * E_[1][1] - E_[0][1] * E_[1][0] >= 0 && E_[0][0] >= 0;
RTC_DCHECK(positive_semi_definite);
// RTC_DCHECK(positive_semi_definite);
if (!positive_semi_definite) {
RTC_LOG(LS_ERROR)
<< "The over-use estimator's covariance matrix is no longer "
"semi-definite.";
"semi-definite. Restarting the matrix"
<< "E_[0][0]:" << E_[0][0] << ",E_[0][1]:" << E_[0][1]
<< ",E_[1][0]:" << E_[1][0] << ",E_[1][1]:" << E_[1][1];
Reset();
}

slope_ = slope_ + K[0] * residual;
Expand All @@ -126,6 +129,22 @@ void OveruseEstimator::Update(int64_t t_delta,
/* BWE_TEST_LOGGING_PLOT(1, "var_noise", now_ms, var_noise_); */
}

void OveruseEstimator::Reset() {
num_of_deltas_ = 0;
slope_ = options_.initial_slope;
offset_ = options_.initial_offset;
prev_offset_ = options_.initial_offset;
avg_noise_ = options_.initial_avg_noise;
var_noise_ = options_.initial_var_noise;
process_noise_[0] = 0;
process_noise_[1] = 0;
ts_delta_hist_.clear();
memcpy(E_, options_.initial_e, sizeof (E_));
memcpy(process_noise_, options_.initial_process_noise,
sizeof (process_noise_));

}

double OveruseEstimator::UpdateMinFramePeriod(double ts_delta) {
double min_frame_period = ts_delta;
if (ts_delta_hist_.size() >= kMinFramePeriodHistoryLength) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class OveruseEstimator {
// based on.
unsigned int num_of_deltas() const { return num_of_deltas_; }

// Resets the estimator
void Reset();

private:
double UpdateMinFramePeriod(double ts_delta);
void UpdateNoiseEstimate(double residual, double ts_delta, bool stable_state);
Expand Down

0 comments on commit d7935de

Please sign in to comment.