[PR #6661] [MERGED] Add native_framerate_limit hook so native mods can lower the frame rate #7017

Closed
opened 2026-11-03 06:32:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6661
Author: @TREYX77
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: feat/native-framerate-limit


📝 Commits (2)

  • fc111a8 Add native_framerate_limit hook so native mods can lower the frame rate
  • 57b8346 Format the framerate limit hook call

📊 Changes

3 files changed (+44 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/game/native_hooks.rs (+15 -0)
📝 crates/horizon-client/src/game/options.rs (+16 -2)
➕ tools/native-hook-fragments/framerate_limit.json (+13 -0)

📄 Description

🤖 Opened by TREYX77's AI agent (Claude Code, Claude Opus 5.5), not by TREYX77 personally.

What and why

Adds a client hook point, native_framerate_limit(focused, minimized, in_world, limit: &mut i32), so a native mod can lower the frame rate limit. The first user is a Dynamic FPS-style native mod that caps FPS while the window is unfocused or minimised. Before this, no hook could change the limit: native_frame only reports elapsed.

  • Game::framerate_limit (options.rs) asks the hook after the inactivity throttle and Battery Mode. It keeps the lower of its own limit and the mod's, so mods can only lower it. Values below 1 are ignored.
  • The hook's default does nothing, so behaviour is unchanged unless a mod hooks it.
  • Its API number comes from the fragment tools/native-hook-fragments/framerate_limit.json, per the fragment README. I did not edit NATIVE_HOOKS_API, native-hooks.json or the API histories.

Fixes #6654

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Horizon-only (a mod hook). It sits at the end of Horizon's port of FramerateLimitTracker.getFramerateLimit and does not change that method's vanilla result.

Other projects' code

None. No code was read from Dynamic FPS or any other project. The hook was designed from Dynamic FPS's public description of what it does.

Self-check

Run on Windows, before the formatting fix in the second commit. After that commit, cargo fmt --all -- --check passes.

**pr_ready** (`tools/pr_ready.py --quick` on LENOVO-TR, against origin/main at 4bc8e359c, 5 min 29 s)

| Check | Result |
| --- | --- |
| Scope | ✅ 3 files, +40 −2 |
| Cargo.lock | ✅ unchanged |
| Public tree | ✅ |
| Python tests | ❌ 598 run, FAILED (errors=1, skipped=12) (2 min 7 s) |
| rustfmt | ❌ failed (12 s) |
| clippy | ✅ (1 min 59 s) |
| tests: horizon-client | ❌ 588 passed, 2 failed (1 min 1 s) |
| doc tests | ✅ 0 passed (3 s) |
| Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses |

Notes on the failures:

  • rustfmt: fixed in the second commit.
  • horizon-client, 2 failures: native_breathing_stays_hookable and native_loot_kinds_stay_hookable search breathing.rs and horizon-world/src/loot.rs for "\n}\n". This checkout uses core.autocrlf=true, so those files have CRLF line endings. This branch doesn't touch either file. catalog_matches_hook_points passes with the new fragment.
  • Python tests, 1 error: I could not see which test errored (the output was truncated), and I have not confirmed whether it is environmental. tests.test_stamp_native_hooks passes. CI on Linux should show the real status.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/6661 **Author:** [@TREYX77](https://github.com/TREYX77) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/native-framerate-limit` --- ### 📝 Commits (2) - [`fc111a8`](https://github.com/horizon-rust/horizon/commit/fc111a8fc08ea7faa03cc1b7ab3ba2f0ecdc2c78) Add native_framerate_limit hook so native mods can lower the frame rate - [`57b8346`](https://github.com/horizon-rust/horizon/commit/57b8346713126f0de30417e585eaa42f717bb04f) Format the framerate limit hook call ### 📊 Changes **3 files changed** (+44 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/native_hooks.rs` (+15 -0) 📝 `crates/horizon-client/src/game/options.rs` (+16 -2) ➕ `tools/native-hook-fragments/framerate_limit.json` (+13 -0) </details> ### 📄 Description > 🤖 Opened by TREYX77's AI agent (Claude Code, Claude Opus 5.5), not by TREYX77 personally. ## What and why Adds a client hook point, `native_framerate_limit(focused, minimized, in_world, limit: &mut i32)`, so a native mod can lower the frame rate limit. The first user is a Dynamic FPS-style native mod that caps FPS while the window is unfocused or minimised. Before this, no hook could change the limit: `native_frame` only reports `elapsed`. - `Game::framerate_limit` (`options.rs`) asks the hook after the inactivity throttle and Battery Mode. It keeps the lower of its own limit and the mod's, so mods can only lower it. Values below 1 are ignored. - The hook's default does nothing, so behaviour is unchanged unless a mod hooks it. - Its API number comes from the fragment `tools/native-hook-fragments/framerate_limit.json`, per the fragment README. I did not edit `NATIVE_HOOKS_API`, `native-hooks.json` or the API histories. Fixes #6654 ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [x] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Horizon-only (a mod hook). It sits at the end of Horizon's port of `FramerateLimitTracker.getFramerateLimit` and does not change that method's vanilla result. ## Other projects' code None. No code was read from Dynamic FPS or any other project. The hook was designed from Dynamic FPS's public description of what it does. ## Self-check Run on Windows, before the formatting fix in the second commit. After that commit, `cargo fmt --all -- --check` passes. ``` **pr_ready** (`tools/pr_ready.py --quick` on LENOVO-TR, against origin/main at 4bc8e359c, 5 min 29 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +40 −2 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 598 run, FAILED (errors=1, skipped=12) (2 min 7 s) | | rustfmt | ❌ failed (12 s) | | clippy | ✅ (1 min 59 s) | | tests: horizon-client | ❌ 588 passed, 2 failed (1 min 1 s) | | doc tests | ✅ 0 passed (3 s) | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | ``` Notes on the failures: - **rustfmt:** fixed in the second commit. - **horizon-client, 2 failures:** `native_breathing_stays_hookable` and `native_loot_kinds_stay_hookable` search `breathing.rs` and `horizon-world/src/loot.rs` for `"\n}\n"`. This checkout uses `core.autocrlf=true`, so those files have CRLF line endings. This branch doesn't touch either file. `catalog_matches_hook_points` passes with the new fragment. - **Python tests, 1 error:** I could not see which test errored (the output was truncated), and I have not confirmed whether it is environmental. `tests.test_stamp_native_hooks` passes. CI on Linux should show the real status. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:32:12 +07:00
Sign in to join this conversation.
No milestone
No project
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.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#7017
No description provided.