From a2dc0053b4f1ed49b6d76155a2223fdae25d9126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olov=20Br=C3=A4ndstr=C3=B6m?= Date: Mon, 14 Oct 2024 05:55:46 -0700 Subject: [PATCH] Update Blink to use environment clock timestamps from RTCStats objects. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://webrtc-review.googlesource.com/c/src/+/363946 added a config flag to tell WebRTC to set environment clock timestamps in RTCStats objects (rather then UTC timestamps). This CL set the config flag, and update the code to handle the new timestamps. This change make all RTCStats timestamps be expressed as Performance time, fixing chromium:369369568. Bug: chromium:369369568 Change-Id: Icc991ba55543bf13a17b526a1247043551e85bab Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5920098 Commit-Queue: Olov Brändström Reviewed-by: Harald Alvestrand Reviewed-by: Henrik Boström Reviewed-by: Johannes Kron Cr-Commit-Position: refs/heads/main@{#1368191} --- ...PeerConnection-getStats-timestamp.https.html | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/webrtc/RTCPeerConnection-getStats-timestamp.https.html b/webrtc/RTCPeerConnection-getStats-timestamp.https.html index 9345d5838d126b..af97521901890e 100644 --- a/webrtc/RTCPeerConnection-getStats-timestamp.https.html +++ b/webrtc/RTCPeerConnection-getStats-timestamp.https.html @@ -11,6 +11,11 @@ // performance.now()` diverge inside of WPTs, so implementers beware that these // tests may give FALSE positives if `timestamp` is implemented as Wall Clock. +// TODO: crbug.com/372749742 - Timestamps from RTCStats differs slightly from +// performance.timeOrigin + performance.now(). We add an epsilon to the +// timestamp checks as a workaround to avoid making the tests flaky. +const kTimeEpsilon = 0.2; + promise_test(async t => { const pc = new RTCPeerConnection(); t.add_cleanup(() => pc.close()); @@ -25,8 +30,10 @@ const peerConnectionStats = report.values().find(stats => stats.type == 'peer-connection'); - assert_less_than_equal(t0, peerConnectionStats.timestamp); - assert_less_than_equal(peerConnectionStats.timestamp, t1); + assert_less_than_equal(t0, peerConnectionStats.timestamp + kTimeEpsilon, + 't0 < timestamp'); + assert_less_than_equal(peerConnectionStats.timestamp, t1 + kTimeEpsilon, + 'timestamp < t1'); }, 'RTCStats.timestamp is expressed as Performance time'); promise_test(async t => { @@ -63,7 +70,9 @@ } const t1 = performance.timeOrigin + performance.now(); - assert_less_than_equal(t0, remoteInboundRtp.timestamp); - assert_less_than_equal(remoteInboundRtp.timestamp, t1); + assert_less_than_equal(t0, remoteInboundRtp.timestamp + kTimeEpsilon, + 't0 < timestamp'); + assert_less_than_equal(remoteInboundRtp.timestamp, t1 + kTimeEpsilon, + 'timestamp < t1'); }, 'RTCRemoteInboundRtpStats.timestamp is expressed as Performance time');