diff --git a/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.cc b/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.cc index 95a000d346..6af0a8c924 100644 --- a/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.cc +++ b/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.cc @@ -62,6 +62,11 @@ AlrDetector::AlrDetector( experiment_settings ? experiment_settings->alr_stop_budget_level_percent / 100.0 : kDefaultStopBudgetLevelRatio), + alr_timeout_( + "alr_timeout", + experiment_settings + ? experiment_settings->alr_timeout + : kDefaultAlrTimeout), alr_budget_(0, true) { ParseFieldTrial({&bandwidth_usage_ratio_, &start_budget_level_ratio_, &stop_budget_level_ratio_}, @@ -73,7 +78,7 @@ AlrDetector::~AlrDetector() {} void AlrDetector::OnBytesSent(size_t bytes_sent, int64_t send_time_ms) { if (!last_send_time_ms_.has_value()) { last_send_time_ms_ = send_time_ms; - // Since the duration for sending the bytes is unknwon, return without + // Since the duration for sending the bytes is unknown, return without // updating alr state. return; } @@ -109,4 +114,18 @@ absl::optional AlrDetector::GetApplicationLimitedRegionStartTime() return alr_started_time_ms_; } +absl::optional AlrDetector::GetApplicationLimitedRegionStartTime( + int64_t at_time_ms) { + if (!alr_started_time_ms_ && *last_send_time_ms_) { + int64_t delta_time_ms = at_time_ms - *last_send_time_ms_; + // If ALR is stopped and we haven't sent any packets for a while, force start. + if (delta_time_ms > alr_timeout_) { + MS_WARN_TAG(bwe, "large delta_time_ms: %ld, forcing alr state change", + delta_time_ms); + alr_started_time_ms_.emplace(at_time_ms); + } + } + return alr_started_time_ms_; +} + } // namespace webrtc diff --git a/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.h b/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.h index e1fbb74525..e1cf8de92b 100644 --- a/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.h +++ b/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.h @@ -43,6 +43,7 @@ class AlrDetector { // Returns time in milliseconds when the current application-limited region // started or empty result if the sender is currently not application-limited. absl::optional GetApplicationLimitedRegionStartTime() const; + absl::optional GetApplicationLimitedRegionStartTime(int64_t at_time_ms); void UpdateBudgetWithElapsedTime(int64_t delta_time_ms); void UpdateBudgetWithBytesSent(size_t bytes_sent); @@ -56,6 +57,7 @@ class AlrDetector { static constexpr double kDefaultBandwidthUsageRatio = 0.65; static constexpr double kDefaultStartBudgetLevelRatio = 0.80; static constexpr double kDefaultStopBudgetLevelRatio = 0.50; + static constexpr int kDefaultAlrTimeout = 3000; AlrDetector(const WebRtcKeyValueConfig* key_value_config, absl::optional experiment_settings); @@ -64,6 +66,7 @@ class AlrDetector { FieldTrialParameter bandwidth_usage_ratio_; FieldTrialParameter start_budget_level_ratio_; FieldTrialParameter stop_budget_level_ratio_; + FieldTrialParameter alr_timeout_; absl::optional last_send_time_ms_; diff --git a/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_network_control.cc b/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_network_control.cc index aced2db317..df64112a41 100644 --- a/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -195,7 +195,7 @@ NetworkControlUpdate GoogCcNetworkController::OnProcessInterval( } bandwidth_estimation_->UpdateEstimate(msg.at_time); absl::optional start_time_ms = - alr_detector_->GetApplicationLimitedRegionStartTime(); + alr_detector_->GetApplicationLimitedRegionStartTime(msg.at_time.ms()); probe_controller_->SetAlrStartTimeMs(start_time_ms); auto probes = probe_controller_->Process(msg.at_time.ms()); diff --git a/worker/deps/libwebrtc/libwebrtc/rtc_base/experiments/alr_experiment.cc b/worker/deps/libwebrtc/libwebrtc/rtc_base/experiments/alr_experiment.cc index 43f36889a8..dd5b5c5957 100644 --- a/worker/deps/libwebrtc/libwebrtc/rtc_base/experiments/alr_experiment.cc +++ b/worker/deps/libwebrtc/libwebrtc/rtc_base/experiments/alr_experiment.cc @@ -26,7 +26,7 @@ const char AlrExperimentSettings::kScreenshareProbingBweExperimentName[] = "WebRTC-ProbingScreenshareBwe"; const char AlrExperimentSettings::kStrictPacingAndProbingExperimentName[] = "WebRTC-StrictPacingAndProbing"; -const char kDefaultProbingScreenshareBweSettings[] = "1.0,2875,80,40,-60,3"; +const char kDefaultProbingScreenshareBweSettings[] = "1.0,2875,80,40,-60,3,3000"; bool AlrExperimentSettings::MaxOneFieldTrialEnabled() { return AlrExperimentSettings::MaxOneFieldTrialEnabled( @@ -71,12 +71,13 @@ AlrExperimentSettings::CreateFromFieldTrial( } AlrExperimentSettings settings; - if (sscanf(group_name.c_str(), "%f,%" PRId64 ",%d,%d,%d,%d", + if (sscanf(group_name.c_str(), "%f,%" PRId64 ",%d,%d,%d,%d,%d", &settings.pacing_factor, &settings.max_paced_queue_time, &settings.alr_bandwidth_usage_percent, &settings.alr_start_budget_level_percent, &settings.alr_stop_budget_level_percent, - &settings.group_id) == 6) { + &settings.group_id, + &settings.alr_timeout) == 7) { ret.emplace(settings); MS_DEBUG_TAG(bwe, "Using ALR experiment settings: " "pacing factor: %f" @@ -84,13 +85,15 @@ AlrExperimentSettings::CreateFromFieldTrial( ", ALR bandwidth usage percent: %d" ", ALR start budget level percent: %d" ", ALR end budget level percent: %d" - ", ALR experiment group ID: %d", + ", ALR experiment group ID: %d" + ", ALR timeout: %d", settings.pacing_factor, settings.max_paced_queue_time, settings.alr_bandwidth_usage_percent, settings.alr_start_budget_level_percent, settings.alr_stop_budget_level_percent, - settings.group_id); + settings.group_id, + settings.alr_timeout); } else { MS_DEBUG_TAG(bwe, "Failed to parse ALR experiment: %s", experiment_name); } diff --git a/worker/deps/libwebrtc/libwebrtc/rtc_base/experiments/alr_experiment.h b/worker/deps/libwebrtc/libwebrtc/rtc_base/experiments/alr_experiment.h index 4d4c38337b..64ab57b85f 100644 --- a/worker/deps/libwebrtc/libwebrtc/rtc_base/experiments/alr_experiment.h +++ b/worker/deps/libwebrtc/libwebrtc/rtc_base/experiments/alr_experiment.h @@ -24,6 +24,7 @@ struct AlrExperimentSettings { int alr_bandwidth_usage_percent; int alr_start_budget_level_percent; int alr_stop_budget_level_percent; + int alr_timeout; // Will be sent to the receive side for stats slicing. // Can be 0..6, because it's sent as a 3 bits value and there's also // reserved value to indicate absence of experiment.