mirror of
https://github.com/ruvnet/RuView
synced 2026-08-03 19:21:42 +00:00
When two render frames land in the same performance.now() tick, `currentTime - lastFrameTime === 0`, so `fps = 1000 / 0 = Infinity`, and `averageFps = averageFps * 0.9 + Infinity * 0.1 = Infinity` poisons the EMA forever after a single zero-dt tick. The UI then displays "Infinity FPS" until reload. Floor deltaTime at 1 ms before the division. That caps displayed FPS at 1000 (far above any real render rate so the cap is never observed in practice) but keeps the EMA finite. Reported in #519 ("Bug 2 — FPS shows Infinity") by @kapilsoni2013 on a 3-node ESP32-S3-WROOM multi-node setup with edge-tier 1 + 2.
This commit is contained in:
@@ -651,14 +651,18 @@ export class PoseRenderer {
|
||||
this.performanceMetrics.frameCount++;
|
||||
|
||||
if (this.performanceMetrics.lastFrameTime > 0) {
|
||||
const deltaTime = currentTime - this.performanceMetrics.lastFrameTime;
|
||||
// Clamp to a minimum dt so consecutive frames within the same
|
||||
// performance.now() tick don't yield Infinity (issue #519 Bug 2).
|
||||
// 1 ms floor caps the displayed FPS at 1000 — far above any real
|
||||
// render rate, but finite so the EMA stays well-defined.
|
||||
const deltaTime = Math.max(currentTime - this.performanceMetrics.lastFrameTime, 1);
|
||||
const fps = 1000 / deltaTime;
|
||||
|
||||
|
||||
// Update average FPS using exponential moving average
|
||||
if (this.performanceMetrics.averageFps === 0) {
|
||||
this.performanceMetrics.averageFps = fps;
|
||||
} else {
|
||||
this.performanceMetrics.averageFps =
|
||||
this.performanceMetrics.averageFps =
|
||||
(this.performanceMetrics.averageFps * 0.9) + (fps * 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user