commit ee90e0761a2211595fb406393f0994dfc46b1a38
parent 738c62b9f1d059d20d88b2720a43c4b68d0c12d0
Author: Dan Baker <dbaker@mozilla.com>
Date: Mon, 1 Dec 2025 23:03:08 -0700
Bug 2000941 - Vendor libwebrtc from de51222243
Upstream commit: https://webrtc.googlesource.com/src/+/de512222430e28f72f1142442289b2ba221620d1
Remove Connection::AlignTime that mimics TimeMillis
Callers were updated to pass current time as Timestamp queried from
clock in Environment, so using same rounding as TimeMillies does is no
longer needed
Bug: webrtc:439515766
Change-Id: I8a5465c26c04811a93fae5c9150b3f6f2ac28181
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/409620
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45705}
Diffstat:
8 files changed, 28 insertions(+), 46 deletions(-)
diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor
@@ -1,4 +1,4 @@
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
-libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T06:00:32.162482+00:00.
+libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T06:02:55.677120+00:00.
# base of lastest vendoring
-b596ae51dc
+de51222243
diff --git a/third_party/libwebrtc/p2p/base/basic_ice_controller.cc b/third_party/libwebrtc/p2p/base/basic_ice_controller.cc
@@ -117,7 +117,7 @@ void BasicIceController::OnConnectionDestroyed(const Connection* connection) {
}
bool BasicIceController::HasPingableConnection() const {
- Timestamp now = Connection::AlignTime(env_.clock().CurrentTime());
+ Timestamp now = env_.clock().CurrentTime();
return absl::c_any_of(connections_, [this, now](const Connection* c) {
return IsPingable(c, now);
});
@@ -138,8 +138,7 @@ IceControllerInterface::PingResult BasicIceController::GetConnectionToPing(
: strong_ping_interval();
const Connection* conn = nullptr;
- if (Connection::AlignTime(env_.clock().CurrentTime()) >=
- last_ping_sent + ping_interval) {
+ if (env_.clock().CurrentTime() >= last_ping_sent + ping_interval) {
conn = FindNextPingableConnection();
}
return PingResult(conn, std::min(ping_interval, check_receiving_interval()));
@@ -153,7 +152,7 @@ void BasicIceController::MarkConnectionPinged(const Connection* conn) {
// Returns the next pingable connection to ping.
const Connection* BasicIceController::FindNextPingableConnection() {
- Timestamp now = Connection::AlignTime(env_.clock().CurrentTime());
+ Timestamp now = env_.clock().CurrentTime();
// Rule 1: Selected connection takes priority over non-selected ones.
if (selected_connection_ && selected_connection_->connected() &&
@@ -453,7 +452,7 @@ BasicIceController::HandleInitialSelectDampening(
return {.connection = new_connection};
}
- Timestamp now = Connection::AlignTime(env_.clock().CurrentTime());
+ Timestamp now = env_.clock().CurrentTime();
int64_t max_delay = 0;
if (new_connection->LastPingReceived() > Timestamp::Zero() &&
field_trials_->initial_select_dampening_ping_received.has_value()) {
@@ -520,11 +519,11 @@ IceControllerInterface::SwitchResult BasicIceController::ShouldSwitchConnection(
// TODO: bugs.webrtc.org/42223979 - consider switching threshold to
// Timestamp type, but beware of subtracting that may lead to negative
// Timestamp that DCHECKs
- std::optional<int64_t> receiving_unchanged_threshold =
- Connection::AlignTime(env_.clock().CurrentTime()).ms() -
+ int64_t receiving_unchanged_threshold_ms =
+ env_.clock().CurrentTime().ms() -
config_.receiving_switching_delay_or_default().ms();
int cmp = CompareConnections(selected_connection_, new_connection,
- receiving_unchanged_threshold,
+ receiving_unchanged_threshold_ms,
&missed_receiving_unchanged_threshold);
std::optional<IceRecheckEvent> recheck_event;
diff --git a/third_party/libwebrtc/p2p/base/connection.cc b/third_party/libwebrtc/p2p/base/connection.cc
@@ -49,11 +49,12 @@
#include "rtc_base/crypto_random.h"
#include "rtc_base/logging.h"
#include "rtc_base/net_helper.h"
+#include "rtc_base/net_helpers.h"
#include "rtc_base/network.h"
#include "rtc_base/network/received_packet.h"
#include "rtc_base/network/sent_packet.h"
#include "rtc_base/network_constants.h"
-#include "rtc_base/platform_thread_types.h"
+#include "rtc_base/socket.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/string_encode.h"
#include "rtc_base/string_utils.h"
@@ -257,7 +258,7 @@ Connection::Connection(const Environment& env,
last_ping_response_received_(Timestamp::Zero()),
receiving_unchanged_since_(Timestamp::Zero()),
state_(IceCandidatePairState::WAITING),
- time_created_(AlignTime(env_.clock().CurrentTime())),
+ time_created_(env_.clock().CurrentTime()),
delta_internal_unix_epoch_(Timestamp::Millis(TimeUTCMillis()) -
time_created_),
field_trials_(&kDefaultFieldTrials),
@@ -340,7 +341,6 @@ void Connection::set_write_state(WriteState value) {
}
void Connection::UpdateReceiving(Timestamp now) {
- now = AlignTime(now);
RTC_DCHECK_RUN_ON(network_thread_);
bool receiving;
if (LastPingSent() < LastPingResponseReceived()) {
@@ -502,7 +502,7 @@ void Connection::OnReadPacket(const ReceivedIpPacket& packet) {
packet.payload().size(), addr, &msg, &remote_ufrag)) {
// The packet did not parse as a valid STUN message
// This is a data packet, pass it along.
- last_data_received_ = AlignTime(env_.clock().CurrentTime());
+ last_data_received_ = env_.clock().CurrentTime();
UpdateReceiving(last_data_received_);
recv_rate_tracker_.AddSamples(packet.payload().size());
stats_.packets_received++;
@@ -685,7 +685,7 @@ void Connection::HandleStunBindingOrGoogPingRequest(IceMessage* msg) {
last_ping_response_received_ <= Timestamp::Zero()) {
if (local_candidate().is_relay() || local_candidate().is_prflx() ||
remote_candidate().is_relay() || remote_candidate().is_prflx()) {
- const Timestamp now = AlignTime(env_.clock().CurrentTime());
+ const Timestamp now = env_.clock().CurrentTime();
if (last_ping_sent_ + kMinExtraPingDelay <= now) {
RTC_LOG(LS_INFO) << ToString()
<< "WebRTC-ExtraICEPing/Sending extra ping"
@@ -1009,7 +1009,6 @@ void Connection::set_selected(bool selected) {
}
void Connection::UpdateState(Timestamp now) {
- now = AlignTime(now);
RTC_DCHECK_RUN_ON(network_thread_);
RTC_DCHECK(port_) << ToDebugId() << ": port_ null in UpdateState()";
if (!port_)
@@ -1092,7 +1091,6 @@ void Connection::Ping() {
void Connection::Ping(Timestamp now,
std::unique_ptr<StunByteStringAttribute> delta) {
- now = AlignTime(now);
RTC_DCHECK_RUN_ON(network_thread_);
RTC_DCHECK(port_) << ToDebugId() << ": port_ null in Ping()";
if (!port_)
@@ -1225,7 +1223,7 @@ Timestamp Connection::LastPingReceived() const {
void Connection::ReceivedPing(const std::optional<std::string>& request_id) {
RTC_DCHECK_RUN_ON(network_thread_);
- last_ping_received_ = AlignTime(env_.clock().CurrentTime());
+ last_ping_received_ = env_.clock().CurrentTime();
last_ping_id_received_ = request_id;
UpdateReceiving(last_ping_received_);
}
@@ -1247,8 +1245,7 @@ void Connection::HandlePiggybackCheckAcknowledgementIfAny(StunMessage* msg) {
RTC_LOG_V(sev) << ToString()
<< ": Received piggyback STUN ping response, id="
<< hex_encode(request_id);
- const TimeDelta rtt =
- AlignTime(env_.clock().CurrentTime()) - iter->sent_time;
+ const TimeDelta rtt = env_.clock().CurrentTime() - iter->sent_time;
ReceivedPingResponse(rtt, request_id, iter->nomination);
}
}
@@ -1279,7 +1276,7 @@ void Connection::ReceivedPingResponse(
acked_nomination_ = nomination.value();
}
- Timestamp now = AlignTime(env_.clock().CurrentTime());
+ Timestamp now = env_.clock().CurrentTime();
total_round_trip_time_ += rtt;
current_round_trip_time_ = rtt;
rtt_estimate_.AddSample(now.ms(), rtt.ms());
@@ -1331,7 +1328,6 @@ bool Connection::active() const {
}
bool Connection::dead(Timestamp now) const {
- now = AlignTime(now);
RTC_DCHECK_RUN_ON(network_thread_);
if (LastReceived() > Timestamp::Zero()) {
// If it has ever received anything, we keep it alive
@@ -1838,7 +1834,6 @@ bool Connection::rtt_converged() const {
bool Connection::missing_responses(Timestamp now) const {
RTC_DCHECK_RUN_ON(network_thread_);
- now = AlignTime(now);
if (pings_since_last_response_.empty()) {
return false;
}
diff --git a/third_party/libwebrtc/p2p/base/connection.h b/third_party/libwebrtc/p2p/base/connection.h
@@ -41,13 +41,12 @@
#include "p2p/base/transport_description.h"
#include "p2p/dtls/dtls_stun_piggyback_callbacks.h"
#include "rtc_base/async_packet_socket.h"
+#include "rtc_base/callback_list.h"
#include "rtc_base/network.h"
#include "rtc_base/network/received_packet.h"
#include "rtc_base/numerics/event_based_exponential_moving_average.h"
#include "rtc_base/rate_tracker.h"
-#include "rtc_base/sigslot_trampoline.h"
#include "rtc_base/system/rtc_export.h"
-#include "rtc_base/third_party/sigslot/sigslot.h"
#include "rtc_base/thread_annotations.h"
#include "rtc_base/weak_ptr.h"
@@ -453,16 +452,6 @@ class RTC_EXPORT Connection : public CandidatePairInterface {
void DeregisterDtlsPiggyback() { dtls_stun_piggyback_callbacks_.reset(); }
- // TODO: bugs.webrtc.org/439515766 - Make this helper an identity or remove it
- // when all users provide time queried from `Clock` and passed around with
- // 'Timestamp' type. Connection class is sensative to current time rounding.
- // While users pass in `TimeMillis()` as current time, use the same rounding.
- // At the same time steer users into passing time using `Timestamp` type
- // queried from a Clock.
- static constexpr Timestamp AlignTime(Timestamp time) {
- return Timestamp::Millis(time.us() / 1000);
- }
-
void NotifyNominatedForTesting(Connection* connection) {
NotifyNominated(connection);
}
@@ -513,7 +502,7 @@ class RTC_EXPORT Connection : public CandidatePairInterface {
const Environment& env() { return env_; }
ConnectionInfo& mutable_stats() { return stats_; }
RateTracker& send_rate_tracker() { return send_rate_tracker_; }
- void set_last_send_data(Timestamp now) { last_send_data_ = AlignTime(now); }
+ void set_last_send_data(Timestamp now) { last_send_data_ = now; }
private:
// Update the local candidate based on the mapped address attribute.
diff --git a/third_party/libwebrtc/p2p/base/p2p_transport_channel.cc b/third_party/libwebrtc/p2p/base/p2p_transport_channel.cc
@@ -66,12 +66,12 @@
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
#include "rtc_base/net_helper.h"
+#include "rtc_base/net_helpers.h"
#include "rtc_base/network.h"
#include "rtc_base/network/received_packet.h"
#include "rtc_base/network/sent_packet.h"
#include "rtc_base/network_constants.h"
#include "rtc_base/network_route.h"
-#include "rtc_base/platform_thread_types.h"
#include "rtc_base/socket.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/thread.h"
@@ -1916,7 +1916,7 @@ void P2PTransportChannel::SwitchSelectedConnectionInternal(
TimeDelta P2PTransportChannel::ComputeEstimatedDisconnectedTime(
Connection* old_connection) {
- Timestamp now = Connection::AlignTime(env_.clock().CurrentTime());
+ Timestamp now = env_.clock().CurrentTime();
// TODO(jonaso): nicer keeps estimate of how frequently data _should_ be
// received, this could be used to give better estimate (if needed).
Timestamp last_data_or_old_ping =
@@ -2113,7 +2113,7 @@ void P2PTransportChannel::PingConnection(Connection* conn) {
}
conn->set_nomination(nomination);
conn->set_use_candidate_attr(use_candidate_attr);
- last_ping_sent_ = Connection::AlignTime(env_.clock().CurrentTime());
+ last_ping_sent_ = env_.clock().CurrentTime();
conn->Ping(last_ping_sent_, stun_dict_writer_.CreateDelta());
}
diff --git a/third_party/libwebrtc/p2p/base/stun_port.cc b/third_party/libwebrtc/p2p/base/stun_port.cc
@@ -89,7 +89,7 @@ class StunBindingRequest : public StunRequest {
}
// The keep-alive requests will be stopped after its lifetime has passed.
- if (WithinLifetime(Connection::AlignTime(env().clock().CurrentTime()))) {
+ if (WithinLifetime(env().clock().CurrentTime())) {
port_->request_manager_.Send(std::make_unique<StunBindingRequest>(
port_, server_addr_, start_time_),
/*delay=*/port_->stun_keepalive_delay());
@@ -112,7 +112,7 @@ class StunBindingRequest : public StunRequest {
attr ? attr->reason()
: "STUN binding response with no error code attribute.");
- Timestamp now = Connection::AlignTime(env().clock().CurrentTime());
+ Timestamp now = env().clock().CurrentTime();
if (WithinLifetime(now) && now - start_time_ < kRetryTimeout) {
port_->request_manager_.Send(std::make_unique<StunBindingRequest>(
port_, server_addr_, start_time_),
@@ -510,8 +510,7 @@ void UDPPort::SendStunBindingRequest(const SocketAddress& stun_addr) {
}
request_manager_.Send(std::make_unique<StunBindingRequest>(
- this, stun_addr,
- Connection::AlignTime(env().clock().CurrentTime())));
+ this, stun_addr, env().clock().CurrentTime()));
});
}
diff --git a/third_party/libwebrtc/p2p/base/tcp_port.cc b/third_party/libwebrtc/p2p/base/tcp_port.cc
@@ -410,7 +410,7 @@ int TCPConnection::Send(const void* data,
tcp_port()->CopyPortInformationToPacketInfo(
&modified_options.info_signaled_after_sent);
int sent = socket_->Send(data, size, modified_options);
- Timestamp now = Connection::AlignTime(env().clock().CurrentTime());
+ Timestamp now = env().clock().CurrentTime();
if (sent < 0) {
mutable_stats().sent_discarded_packets++;
error_ = socket_->GetError();
diff --git a/third_party/libwebrtc/test/peer_scenario/tests/l4s_test.cc b/third_party/libwebrtc/test/peer_scenario/tests/l4s_test.cc
@@ -500,8 +500,8 @@ TEST(L4STest, CallerAdaptToLinkCapacityOnNetworkWithEcn) {
s.ProcessMessages(TimeDelta::Seconds(3));
DataRate available_bwe =
GetAvailableSendBitrate(GetStatsAndProcess(s, caller));
- EXPECT_GT(available_bwe.kbps(), 450);
- EXPECT_LT(available_bwe.kbps(), 610);
+ EXPECT_GT(available_bwe, DataRate::KilobitsPerSec(450));
+ EXPECT_LT(available_bwe, DataRate::KilobitsPerSec(610));
}
TEST(L4STest, SendsEct1UntilFirstFeedback) {