From a04a0f5d0340fd46a69e5766ca54526b0b0e3df7 Mon Sep 17 00:00:00 2001 From: Guillaume Meunier Date: Sun, 13 Jul 2025 16:28:17 +0200 Subject: [PATCH] Avoid unrealistic frame times when accumulating metrics --- client/scenes/stream_stats.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/scenes/stream_stats.cpp b/client/scenes/stream_stats.cpp index 2ae94af2..2cfdff74 100644 --- a/client/scenes/stream_stats.cpp +++ b/client/scenes/stream_stats.cpp @@ -87,6 +87,11 @@ void scenes::stream::accumulate_metrics(XrTime predicted_display_time, const std float dt = (predicted_display_time - last_metric_time) * 1e-9f; + // Sometimes the render function can be called with almost the same predicted_display_time, + // which can cause issues with the bandwidth estimation. + if (dt < 0.001f) + return; + bandwidth_rx = 0.8 * bandwidth_rx + 0.2 * float(rx - bytes_received) / dt; bandwidth_tx = 0.8 * bandwidth_tx + 0.2 * float(tx - bytes_sent) / dt;