fix(xgameruntime): guard frame_counter against 0 ms division, non-finite elapsed, and empty CSV path #375

Merged
Lewandox merged 1 commit from upstream-pr/375 into main 2026-11-26 13:57:27 +00:00
Lewandox commented 2026-11-26 13:46:05 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Lewandox on 2026-11-26T13:46:05Z.


Summary

Fixes three edge-case bugs in crates/anyxboxx-xgameruntime/src/frame_counter.rs:

  1. Division by zero on slowest_ms == 0.0: 1000.0 / report.slowest_ms produced inf in trace logs and the window title (1 % bas inf) when frames completed within the same monotonic clock tick. Extracted low_fps(slowest_ms: f64) -> f64 returning 0.0 when slowest_ms is non-positive or non-finite.
  2. Non-finite elapsed in summarise: summarise only checked elapsed <= 0.0, accepting f64::INFINITY or f64::NAN. Now rejects !elapsed.is_finite() || elapsed <= 0.0.
  3. Empty ANYXBOXX_FPS_CSV: write_csv now ignores an empty ANYXBOXX_FPS_CSV environment variable instead of attempting to open "".

Verification

  • cargo fmt -p anyxboxx-xgameruntime -- --check — pass
  • cargo clippy -p anyxboxx-xgameruntime --no-deps --all-targets -- -D warnings — pass
  • cargo test -p anyxboxx-xgameruntime frame_counter::tests — all passed, 0 failed
<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:6628005746 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/375). Originally posted by [Lewandox](https://github.com/Lewandox) on 2026-11-26T13:46:05Z. --- ## Summary Fixes three edge-case bugs in `crates/anyxboxx-xgameruntime/src/frame_counter.rs`: 1. **Division by zero on `slowest_ms == 0.0`**: `1000.0 / report.slowest_ms` produced `inf` in trace logs and the window title (`1 % bas inf`) when frames completed within the same monotonic clock tick. Extracted `low_fps(slowest_ms: f64) -> f64` returning `0.0` when `slowest_ms` is non-positive or non-finite. 2. **Non-finite `elapsed` in `summarise`**: `summarise` only checked `elapsed <= 0.0`, accepting `f64::INFINITY` or `f64::NAN`. Now rejects `!elapsed.is_finite() || elapsed <= 0.0`. 3. **Empty `ANYXBOXX_FPS_CSV`**: `write_csv` now ignores an empty `ANYXBOXX_FPS_CSV` environment variable instead of attempting to open `""`. ### Verification - `cargo fmt -p anyxboxx-xgameruntime -- --check` — pass - `cargo clippy -p anyxboxx-xgameruntime --no-deps --all-targets -- -D warnings` — pass - `cargo test -p anyxboxx-xgameruntime frame_counter::tests` — all passed, 0 failed
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LooperSalty/AnyXboxX!375
No description provided.