fix(display): correct FPS calculation in all display backends

BUG: FPS display showed incorrect values (e.g., >1000 when actual FPS was ~60)

ROOT CAUSE: Display backends were looking for avg_ms at the wrong level
in the stats dictionary. The PerformanceMonitor.get_stats() returns:
  {
    'frame_count': N,
    'pipeline': {'avg_ms': X, ...},
    'effects': {...}
  }

But the display backends were using:
  avg_ms = stats.get('avg_ms', 0)  #  Returns 0 (not found at top level)

FIXED: All display backends now use:
  avg_ms = stats.get('pipeline', {}).get('avg_ms', 0)  #  Correct path

Updated backends:
- engine/display/backends/terminal.py
- engine/display/backends/websocket.py
- engine/display/backends/sixel.py
- engine/display/backends/pygame.py
- engine/display/backends/kitty.py

Now FPS displays correctly (e.g., 60 FPS for 16.67ms avg frame time).
This commit is contained in:
2026-03-16 20:03:53 -07:00
parent 015d563c4a
commit 73ca72d920
5 changed files with 5 additions and 5 deletions

View File

@@ -81,7 +81,7 @@ class KittyDisplay:
monitor = get_monitor() monitor = get_monitor()
if monitor: if monitor:
stats = monitor.get_stats() stats = monitor.get_stats()
avg_ms = stats.get("avg_ms", 0) if stats else 0 avg_ms = stats.get("pipeline", {}).get("avg_ms", 0) if stats else 0
frame_count = stats.get("frame_count", 0) if stats else 0 frame_count = stats.get("frame_count", 0) if stats else 0
if avg_ms and frame_count > 0: if avg_ms and frame_count > 0:
fps = 1000.0 / avg_ms fps = 1000.0 / avg_ms

View File

@@ -173,7 +173,7 @@ class PygameDisplay:
monitor = get_monitor() monitor = get_monitor()
if monitor: if monitor:
stats = monitor.get_stats() stats = monitor.get_stats()
avg_ms = stats.get("avg_ms", 0) if stats else 0 avg_ms = stats.get("pipeline", {}).get("avg_ms", 0) if stats else 0
frame_count = stats.get("frame_count", 0) if stats else 0 frame_count = stats.get("frame_count", 0) if stats else 0
if avg_ms and frame_count > 0: if avg_ms and frame_count > 0:
fps = 1000.0 / avg_ms fps = 1000.0 / avg_ms

View File

@@ -135,7 +135,7 @@ class SixelDisplay:
monitor = get_monitor() monitor = get_monitor()
if monitor: if monitor:
stats = monitor.get_stats() stats = monitor.get_stats()
avg_ms = stats.get("avg_ms", 0) if stats else 0 avg_ms = stats.get("pipeline", {}).get("avg_ms", 0) if stats else 0
frame_count = stats.get("frame_count", 0) if stats else 0 frame_count = stats.get("frame_count", 0) if stats else 0
if avg_ms and frame_count > 0: if avg_ms and frame_count > 0:
fps = 1000.0 / avg_ms fps = 1000.0 / avg_ms

View File

@@ -93,7 +93,7 @@ class TerminalDisplay:
monitor = get_monitor() monitor = get_monitor()
if monitor: if monitor:
stats = monitor.get_stats() stats = monitor.get_stats()
avg_ms = stats.get("avg_ms", 0) if stats else 0 avg_ms = stats.get("pipeline", {}).get("avg_ms", 0) if stats else 0
frame_count = stats.get("frame_count", 0) if stats else 0 frame_count = stats.get("frame_count", 0) if stats else 0
if avg_ms and frame_count > 0: if avg_ms and frame_count > 0:
fps = 1000.0 / avg_ms fps = 1000.0 / avg_ms

View File

@@ -111,7 +111,7 @@ class WebSocketDisplay:
monitor = get_monitor() monitor = get_monitor()
if monitor: if monitor:
stats = monitor.get_stats() stats = monitor.get_stats()
avg_ms = stats.get("avg_ms", 0) if stats else 0 avg_ms = stats.get("pipeline", {}).get("avg_ms", 0) if stats else 0
frame_count = stats.get("frame_count", 0) if stats else 0 frame_count = stats.get("frame_count", 0) if stats else 0
if avg_ms and frame_count > 0: if avg_ms and frame_count > 0:
fps = 1000.0 / avg_ms fps = 1000.0 / avg_ms