[PR #740] [MERGED] Startup: load resources on a worker behind a loading screen (#712) #2773

Closed
opened 2026-11-02 15:58:55 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/740
Author: @rdbtCVS
Created: 10/17/2026
Status: ✅ Merged
Merged: 10/17/2026
Merged by: @ludovic111

Base: main ← Head: t3code/08bad3fd


📝 Commits (1)

  • 4be192a Startup: load resources on a worker behind a loading screen (#712)

📊 Changes

2 files changed (+652 additions, -65 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+631 -65)
📝 crates/horizon-client/src/level_loading.rs (+21 -0)

📄 Description

Part of #712 (stage 1: asynchronous startup behind a loading screen).

What

An ordinary launch now enters the event loop immediately: the window and a loading screen appear after ~0.3–0.5 s while the existing resource-loading sequence runs on a resource-loader thread. The loading screen shows the current stage and a progress bar. When loading finishes, the real renderer, game and title screen replace it on the same window.

Harness, dedicated and scripted runs keep the fully-synchronous path unchanged, so their output stays byte-identical:

  • --frames, --world-frames, --benchmark, --control (including --control-socket), --dedicated
  • HORIZON_MENU_STYLE=classic
  • HORIZON_DISPENSE_FIXTURE, HORIZON_SCULK_FIXTURE, HORIZON_COMMAND_SCRIPT, HORIZON_NET_REPORT

The launcher's normal Play path (and --server, --world, --creative, …) takes the new path; horizon-ctl/agent runs keep using the control socket and stay synchronous.

How

  • load_resources is the old loading sequence, unchanged, with a stage callback.
  • start_game is the old post-load setup (Game::new, packs error screen, benchmark, mods, control socket, world/server/title selection, fixtures).
  • Loading owns the early window/renderer/atlas; App is Loading | Ready(Game). The renderer swaps the loading surface for the real one, reusing the loader's device (release_surface + build_renderer(previous)), as reload_resources already does.
  • Audio is created on the render thread after the join; lang metadata is set on the worker (process-wide RwLock).
  • title_shown still fires on the real title, never on the loading screen.

No new dependencies. Stage 2+ (deferring gameplay resources and making the menu interactive while they load) is not in this PR.

Testing

  • cargo build --profile fast -p horizon-client
  • cargo test -p horizon-client --locked — 913 passed
  • HORIZON_NO_AUDIO=1 ./target/fast/horizon-client --offscreen --frames 3 --resources … --smoke-report /tmp/s.json — sync path, 3 frames, report written
  • Async path, offscreen and real window: loading screen at 362–444 ms, real renderer swapped in, title reached, no surface errors
  • python3 tools/pr_ready.py --base origin/main

pr_ready (tools/pr_ready.py on archlinux, against origin/main at 4a56e505a, 1 min 8 s)

Check Result
Scope ⚠️ 2 files, +652 −65; 717 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (5 s)
clippy ✅ (56 s)
tests: horizon-client ✅ 913 passed (7 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The scope warning is expected: the async startup skeleton (loader, loading screen, dual-renderer swap, App state) is one coherent unit; splitting it would leave a half-used loading screen.


🔄 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/740 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `t3code/08bad3fd` --- ### 📝 Commits (1) - [`4be192a`](https://github.com/horizon-rust/horizon/commit/4be192a4b89aef22297faeb2ea9cea41db7cead3) Startup: load resources on a worker behind a loading screen (#712) ### 📊 Changes **2 files changed** (+652 additions, -65 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+631 -65) 📝 `crates/horizon-client/src/level_loading.rs` (+21 -0) </details> ### 📄 Description Part of #712 (stage 1: asynchronous startup behind a loading screen). ## What An ordinary launch now enters the event loop immediately: the window and a loading screen appear after ~0.3–0.5 s while the existing resource-loading sequence runs on a `resource-loader` thread. The loading screen shows the current stage and a progress bar. When loading finishes, the real renderer, game and title screen replace it on the same window. Harness, dedicated and scripted runs keep the fully-synchronous path unchanged, so their output stays byte-identical: - `--frames`, `--world-frames`, `--benchmark`, `--control` (including `--control-socket`), `--dedicated` - `HORIZON_MENU_STYLE=classic` - `HORIZON_DISPENSE_FIXTURE`, `HORIZON_SCULK_FIXTURE`, `HORIZON_COMMAND_SCRIPT`, `HORIZON_NET_REPORT` The launcher's normal Play path (and `--server`, `--world`, `--creative`, …) takes the new path; `horizon-ctl`/agent runs keep using the control socket and stay synchronous. ## How - `load_resources` is the old loading sequence, unchanged, with a stage callback. - `start_game` is the old post-load setup (`Game::new`, packs error screen, benchmark, mods, control socket, world/server/title selection, fixtures). - `Loading` owns the early window/renderer/atlas; `App` is `Loading | Ready(Game)`. The renderer swaps the loading surface for the real one, reusing the loader's device (`release_surface` + `build_renderer(previous)`), as `reload_resources` already does. - Audio is created on the render thread after the join; `lang` metadata is set on the worker (process-wide `RwLock`). - `title_shown` still fires on the real title, never on the loading screen. No new dependencies. Stage 2+ (deferring gameplay resources and making the menu interactive while they load) is not in this PR. ## Testing - `cargo build --profile fast -p horizon-client` - `cargo test -p horizon-client --locked` — 913 passed - `HORIZON_NO_AUDIO=1 ./target/fast/horizon-client --offscreen --frames 3 --resources … --smoke-report /tmp/s.json` — sync path, 3 frames, report written - Async path, offscreen and real window: loading screen at 362–444 ms, real renderer swapped in, title reached, no surface errors - `python3 tools/pr_ready.py --base origin/main` **pr_ready** (`tools/pr_ready.py` on archlinux, against origin/main at 4a56e505a, 1 min 8 s) | Check | Result | | --- | --- | | Scope | ⚠️ 2 files, +652 −65; 717 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (5 s) | | clippy | ✅ (56 s) | | tests: horizon-client | ✅ 913 passed (7 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The scope warning is expected: the async startup skeleton (loader, loading screen, dual-renderer swap, `App` state) is one coherent unit; splitting it would leave a half-used loading screen. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:58:55 +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#2773
No description provided.