w3c / webrtc-pc

WebRTC 1.0 API
https://w3c.github.io/webrtc-pc/
Other
439 stars 115 forks source link

RTCStats::timestamp discrepancy between webrtc-stats and webrtc-pc #3004

Closed henbos closed 1 month ago

henbos commented 2 months ago

In webrtc-stats it says:

Timestamps are expressed with DOMHighResTimeStamp [HIGHRES-TIME], and are defined as Performance.timeOrigin + Performance.now() at the time the information is collected.

Which is consistent with most timestamps that we've defined for the last several years and ensures monotonically incrementing etc, so it's always possible to do "delta fooStat / delta timestamp".

But the timestamp definition in webrtc-pc is really old and it says:

The timestamp, of type DOMHighResTimeStamp, associated with this object. The time is relative to the UNIX epoch (Jan 1, 1970, UTC).

It doesn't really say but this sounds like a wall clock that is not necessarily always monotonically incrementing. I think this is a mistake and it should say Performance here as well to align with all other timestamps, otherwise there will be edge cases where things break.

We noticed a bug relating to wall clock vs performance where it would diverge if the laptop went to sleep and then the page resumed...