Skip to content

Fix panic when animation_fps is set to 0.0#319

Open
corpooo wants to merge 1 commit intoacsandmann:mainfrom
corpooo:pr/animation-fps-zero-panic
Open

Fix panic when animation_fps is set to 0.0#319
corpooo wants to merge 1 commit intoacsandmann:mainfrom
corpooo:pr/animation-fps-zero-panic

Conversation

@corpooo
Copy link
Copy Markdown
Contributor

@corpooo corpooo commented Mar 27, 2026

Summary

  • handle animation_fps = 0.0 without panicking
  • use the display refresh rate when the config leaves fps at zero
  • fall back to 60 Hz if the refresh rate cannot be determined

Why

Animation::new currently computes 1.0 / fps directly. When fps is 0.0, that produces infinity and panics during Duration::from_secs_f64(...).

The config comment already implies that 0.0 should mean "use the display refresh rate", so this makes the implementation match the existing configuration contract.

Verification

  • cargo build --profile release-fast --bin rift
  • cargo test animation -- --nocapture

`Animation::new` computes `Duration::from_secs_f64(1.0 / fps)`. When
fps is 0.0 this produces infinity, which panics inside the standard
library's Duration conversion.

Use the display's native refresh rate (via `get_display_refresh_rate()`)
when fps is 0.0, as originally intended by the config comment. Falls
back to 60 Hz if the rate cannot be determined.

Fixes acsandmann#316

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant