[PR #5603] [MERGED] --headless: a client with no display, window or GPU (#4951, 2/3) #6384

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5603
Author: @Solenopsisbot
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: headless/client


📝 Commits (4)

  • a3c5b5b --headless: a client with no display, window or GPU
  • 9ec42d2 Headless: no section meshes while there is no renderer
  • 3f71430 Merge remote-tracking branch 'origin/main' into headless/client
  • 2a9d7f2 --headless: stop the narrator when the loop ends; idle's doc back on idle

📊 Changes

5 files changed (+154 additions, -10 deletions)

View changed files

📝 crates/horizon-client/src/bin/horizon-ctl/commands.rs (+2 -1)
📝 crates/horizon-client/src/game.rs (+48 -8)
➕ crates/horizon-client/src/game/headless.rs (+98 -0)
📝 docs/agent-control.md (+5 -0)
📝 docs/horizon-ctl-commands.md (+1 -1)

📄 Description

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

What and why

Part 2 of #4951 (a headless client), on top of #4996 (merged): the --headless flag and the game's own loop.

horizon-client --headless (horizon-ctl launch --headless) runs where there is no display server, such as an SSH session or a server. winit's EventLoop::new() fails without DISPLAY or WAYLAND_DISPLAY, even for --offscreen, so the game runs its own loop (game/headless.rs) through #4996's EventLoopCtl handle:

  • The loop: one step per tick (50 ms). Each step is Game::idle, which runs the frame through the RedrawRequested path with WindowId::dummy(); handle_window_event takes that id when there is no window.
  • What it skips: no window, no renderer, silent audio, and no loading screen (synchronous startup). It counts as offscreen for everything else.
  • Quitting: it saves the world as a window's game does. Game::shut_down is now shared with winit's exiting.
  • Input: it plays through the control socket only. Commands that need the screen's pixels (screenshot, clicks at GUI points) answer "no renderer yet". Part 3 adds vision on|off.
  • No meshing: a headless game doesn't mesh sections while it has no renderer, as a server's streaming doesn't.

Measured on a Ryzen 7 3700X with no DISPLAY, a single-player world through the server thread:

  • Works: the world opens; move, command and menus work through the control socket; no GPU device is opened; the world saves on quit.
  • Meshing: 0 sections meshed instead of 21,287.
  • Memory: 853 MB resident instead of 1,117 MB.
  • CPU: in steady state the client's own thread uses 1.6% of a core, and the whole game about 15%, the server thread included.

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: vanilla has no headless client. Nothing changes without --headless.

Self-check

pr_ready (tools/pr_ready.py on cytonic, against origin/main at c9d8e3efa, 27 min 44 s)

Check Result
Scope ✅ 5 files, +152 −10
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 510 passed (49 s)
rustfmt ✅ (12 s)
clippy ✅ (1 min 52 s)
tests: horizon-client ✅ 1578 passed (5 min 32 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ❌ 37 affected, 34 passed, failed: dedicated_server, online_mode (19 min 13 s)

Both parity failures happen on main without this PR. I ran them on a clean worktree of c9d8e3efa on the same machine:

  • online_mode: IndexError at test_online_mode_parity.py:310, the same on main. The fake session service logs an entry shorter than the harness expects. It looks like another program probing the new port, as 559ecb02f describes, in a form that commit's filter doesn't catch.
  • dedicated_server: one extra multiplayer.player.joined at play start, as reported in #4996.

🤖 Generated with Claude Code


🔄 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/5603 **Author:** [@Solenopsisbot](https://github.com/Solenopsisbot) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `headless/client` --- ### 📝 Commits (4) - [`a3c5b5b`](https://github.com/horizon-rust/horizon/commit/a3c5b5b57a1912551ee282ba28fb8876b08a8b70) --headless: a client with no display, window or GPU - [`9ec42d2`](https://github.com/horizon-rust/horizon/commit/9ec42d2f2bc34ec886d73fef883f33ba3e4f963c) Headless: no section meshes while there is no renderer - [`3f71430`](https://github.com/horizon-rust/horizon/commit/3f714300eda7c446f05b8a35f2b0b199689a0682) Merge remote-tracking branch 'origin/main' into headless/client - [`2a9d7f2`](https://github.com/horizon-rust/horizon/commit/2a9d7f2839489363cf891f3f9568a38982d1503f) --headless: stop the narrator when the loop ends; idle's doc back on idle ### 📊 Changes **5 files changed** (+154 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/bin/horizon-ctl/commands.rs` (+2 -1) 📝 `crates/horizon-client/src/game.rs` (+48 -8) ➕ `crates/horizon-client/src/game/headless.rs` (+98 -0) 📝 `docs/agent-control.md` (+5 -0) 📝 `docs/horizon-ctl-commands.md` (+1 -1) </details> ### 📄 Description > 🤖 Opened by Solenopsisbot's AI agent (Claude Code, Claude Opus 5.5), not by Solenopsisbot personally. ## What and why Part 2 of #4951 (a headless client), on top of #4996 (merged): the `--headless` flag and the game's own loop. `horizon-client --headless` (`horizon-ctl launch --headless`) runs where there is no display server, such as an SSH session or a server. winit's `EventLoop::new()` fails without `DISPLAY` or `WAYLAND_DISPLAY`, even for `--offscreen`, so the game runs its own loop (`game/headless.rs`) through #4996's `EventLoopCtl` handle: - **The loop:** one step per tick (50 ms). Each step is `Game::idle`, which runs the frame through the `RedrawRequested` path with `WindowId::dummy()`; `handle_window_event` takes that id when there is no window. - **What it skips:** no window, no renderer, silent audio, and no loading screen (synchronous startup). It counts as `offscreen` for everything else. - **Quitting:** it saves the world as a window's game does. `Game::shut_down` is now shared with winit's `exiting`. - **Input:** it plays through the control socket only. Commands that need the screen's pixels (`screenshot`, clicks at GUI points) answer "no renderer yet". Part 3 adds `vision on|off`. - **No meshing:** a headless game doesn't mesh sections while it has no renderer, as a server's streaming doesn't. Measured on a Ryzen 7 3700X with no `DISPLAY`, a single-player world through the server thread: - **Works:** the world opens; `move`, `command` and menus work through the control socket; no GPU device is opened; the world saves on `quit`. - **Meshing:** 0 sections meshed instead of 21,287. - **Memory:** 853 MB resident instead of 1,117 MB. - **CPU:** in steady state the client's own thread uses 1.6% of a core, and the whole game about 15%, the server thread included. ## 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: vanilla has no headless client. Nothing changes without `--headless`. ## Self-check **pr_ready** (`tools/pr_ready.py` on cytonic, against origin/main at c9d8e3efa, 27 min 44 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +152 −10 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 510 passed (49 s) | | rustfmt | ✅ (12 s) | | clippy | ✅ (1 min 52 s) | | tests: horizon-client | ✅ 1578 passed (5 min 32 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ❌ 37 affected, 34 passed, failed: dedicated_server, online_mode (19 min 13 s) | Both parity failures happen on main without this PR. I ran them on a clean worktree of c9d8e3efa on the same machine: - **`online_mode`:** `IndexError` at `test_online_mode_parity.py:310`, the same on main. The fake session service logs an entry shorter than the harness expects. It looks like another program probing the new port, as 559ecb02f describes, in a form that commit's filter doesn't catch. - **`dedicated_server`:** one extra `multiplayer.player.joined` at play start, as reported in #4996. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:19:45 +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#6384
No description provided.