gpu: saturate bink_movie(false) counter at zero #44

Merged
ahmetbagci8 merged 1 commit from upstream-pr/44 into dev 2026-11-29 20:55:42 +00:00
ahmetbagci8 commented 2026-11-29 20:42:24 +00:00 (Migrated from github.com)

Imported from edsuuu/VI-BR-PORT. Originally posted by ahmetbagci8 on 2026-11-29T20:42:24Z.


Problem

In crates/victory-gpu/src/frame.rs, ink_movie(false) executes MOVIES.fetch_sub(1, Ordering::Relaxed). If ink_movie(false) is ever called when MOVIES == 0 (for example closing an unbalanced Bink handle), the counter wraps to u64::MAX, permanently locking the frame pacer into 30 Hz Pacing::Video mode for the rest of the session.

Fix

Use MOVIES.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |n| n.checked_sub(1)) so decrementing at zero is a no-op. Added unit test ink_movie_stop_at_zero_does_not_underflow.

Verification

  • cargo test -p victory-gpu --lib frame::tests (6 passed, 0 failed)
  • cargo clippy -p victory-gpu --tests (0 warnings)
<!-- greyfinch-sync:edsuuu/VI-BR-PORT:issue:5554908792 --> Imported from [edsuuu/VI-BR-PORT](https://github.com/edsuuu/VI-BR-PORT/pull/44). Originally posted by [ahmetbagci8](https://github.com/ahmetbagci8) on 2026-11-29T20:42:24Z. --- ## Problem In crates/victory-gpu/src/frame.rs, ink_movie(false) executes MOVIES.fetch_sub(1, Ordering::Relaxed). If ink_movie(false) is ever called when MOVIES == 0 (for example closing an unbalanced Bink handle), the counter wraps to u64::MAX, permanently locking the frame pacer into 30 Hz Pacing::Video mode for the rest of the session. ## Fix Use MOVIES.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |n| n.checked_sub(1)) so decrementing at zero is a no-op. Added unit test ink_movie_stop_at_zero_does_not_underflow. ## Verification - cargo test -p victory-gpu --lib frame::tests (6 passed, 0 failed) - cargo clippy -p victory-gpu --tests (0 warnings)
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
edsuuu/VI-BR-PORT!44
No description provided.