[PR #3649] [MERGED] startup: report why resource loading failed instead of "loader stopped" #5121

Closed
opened 2026-11-03 05:10:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3649
Author: @d3grando
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix-3597


📝 Commits (1)

  • 9f28fe8 startup: report why resource loading failed instead of "loader stopped"

📊 Changes

2 files changed (+110 additions, -6 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+43 -0)
📝 crates/horizon-client/src/game/startup_menu.rs (+67 -6)

📄 Description

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

What and why

Fixes #3597. The same crash message is reported in #3593, #3532, #3394, #3324 and #3118, and #3247 (opening horizon-client.exe directly) is most likely the same; this should cover them too.

When a launch failed to load its resources, the crash report always said resource loader stopped before finishing. Players never saw the actual error, which in these reports is a missing prepared-files folder.

Root cause. The loader thread doesn't panic. It sends LoaderMsg::Done(Err(..)) and then exits normally. App::about_to_wait take()s that result, stores it as loading.error and calls event_loop.exit(). winit then runs Loading::about_to_wait one more time. That call goes into poll_menu_resources with loaded == None and finds the channel disconnected, because the loader has already finished. It then overwrites self.error with the generic "stopped before finishing". The real message (...os error 3... Prepare resources with the launcher, or: horizon-prepare --prepare) is thrown away. So every failed load showed the same text: a missing .local/horizon-client/26.3 (horizon-client.exe opened directly, as in #3247/#3532), or a stale or incomplete prepared folder.

Fix (game.rs, game/startup_menu.rs):

  • Loading::about_to_wait keeps the first error. Once an error is set it asks to exit again and does nothing else.
  • Loading now records that Done arrived (delivered). poll_menu_resources stops reading the channel after that, so a channel that closes after Done is no longer treated as a failure. This also covers the Ok(None) handoff path.
  • A loader that really panics now has its panic payload in the error (resource loader stopped before finishing: <message>). The pack-reload join's "resource loader panicked" gets the payload too.
  • run() checks for horizon-resources.json (the prepared-files manifest that Assets::load reads first) before any window, Discord presence or loader starts. If it is missing, the error names the absolute folder it looked in and says how to get the files: start from the launcher, run horizon-prepare --prepare, or pass --resources.

Vanilla reference

Horizon-only: this is Horizon's startup and error reporting, and vanilla has no prepared-resources step. No parity harness applies.

Tests

New tests:

  • startup_menu::tests::a_failed_generation_keeps_its_error_after_the_loader_ends
  • startup_menu::tests::a_panicking_loader_reports_its_panic
  • startup_cpu_tests::a_folder_without_prepared_files_is_named_before_loading

The existing disconnected_core_worker_is_reported_instead_of_waiting_forever still passes.

Before (only the code reverted, tests kept):

test game::startup_cpu_tests::a_folder_without_prepared_files_is_named_before_loading ... FAILED
test game::startup_menu::tests::a_failed_generation_keeps_its_error_after_the_loader_ends ... FAILED
  called `Result::unwrap()` on an `Err` value: "resource loader stopped before finishing"
test game::startup_menu::tests::a_panicking_loader_reports_its_panic ... FAILED
  left: "resource loader stopped before finishing"
 right: "resource loader stopped before finishing: atlas has no fonts"
test result: FAILED. 4 passed; 3 failed

After:

test game::startup_cpu_tests::a_folder_without_prepared_files_is_named_before_loading ... ok
test game::startup_menu::tests::a_failed_generation_keeps_its_error_after_the_loader_ends ... ok
test game::startup_menu::tests::a_panicking_loader_reports_its_panic ... ok
test game::startup_menu::tests::disconnected_core_worker_is_reported_instead_of_waiting_forever ... ok
test game::startup_menu::tests::menu_is_usable_while_the_core_worker_is_blocked ... ok
test game::startup_menu::tests::queued_server_keeps_address_and_player_identity ... ok
test game::startup_cpu_tests::worker_prepares_owned_models_and_inventory_before_handoff ... ok
test result: ok. 7 passed; 0 failed

In game (Windows 11)

  • Before: horizon-client.exe started from an empty folder (no .local) gave the same log as the issue: title panorama unavailable (os error 3), UI bundle ready, loading the title artwork, then resource loader stopped before finishing and a crash report with only that line. A folder with a stale horizon-resources.json (wrong data_version) gave the same message.
  • After, empty folder: the game exits before opening a window, and the log and crash report say:
    Horizon's prepared game files are missing: no horizon-resources.json in <absolute folder>\.local\horizon-client\26.3 / Start Horizon from the Horizon launcher, which downloads and prepares them, or prepare them with: horizon-prepare --prepare (or pass --resources <folder>).
  • After, stale folder: the report now gives the real cause: resources do not match Horizon's pinned data version / Prepare resources with the launcher, or: horizon-prepare --prepare.
  • After, with real prepared resources: a normal launch through horizon-ctl launch still reaches the world (creative, standing on grass, screenshot taken), so a successful load is unchanged.

Self-check

tools/pr_ready.py doesn't run on Windows, so I ran its steps by hand:

cargo fmt --all -- --check                                                         # ok
cargo clippy --profile fast -p horizon-client --features mods --all-targets -- -D warnings   # ok
cargo test --profile fast -p horizon-client --features mods --bin horizon-client -- startup_menu:: startup_cpu_tests::   # 7 passed
cargo build --profile fast -p horizon-client --features mods --bins                # ok

🤖 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/3649 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3597` --- ### 📝 Commits (1) - [`9f28fe8`](https://github.com/horizon-rust/horizon/commit/9f28fe89037369e333866d73d3c7a3fec76bfccc) startup: report why resource loading failed instead of "loader stopped" ### 📊 Changes **2 files changed** (+110 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+43 -0) 📝 `crates/horizon-client/src/game/startup_menu.rs` (+67 -6) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3597. The same crash message is reported in #3593, #3532, #3394, #3324 and #3118, and #3247 (opening `horizon-client.exe` directly) is most likely the same; this should cover them too. When a launch failed to load its resources, the crash report always said `resource loader stopped before finishing`. Players never saw the actual error, which in these reports is a missing prepared-files folder. **Root cause.** The loader thread doesn't panic. It sends `LoaderMsg::Done(Err(..))` and then exits normally. `App::about_to_wait` `take()`s that result, stores it as `loading.error` and calls `event_loop.exit()`. winit then runs `Loading::about_to_wait` one more time. That call goes into `poll_menu_resources` with `loaded == None` and finds the channel disconnected, because the loader has already finished. It then overwrites `self.error` with the generic "stopped before finishing". The real message (`...os error 3... Prepare resources with the launcher, or: horizon-prepare --prepare`) is thrown away. So every failed load showed the same text: a missing `.local/horizon-client/26.3` (horizon-client.exe opened directly, as in #3247/#3532), or a stale or incomplete prepared folder. **Fix** (`game.rs`, `game/startup_menu.rs`): - `Loading::about_to_wait` keeps the first error. Once an error is set it asks to exit again and does nothing else. - `Loading` now records that `Done` arrived (`delivered`). `poll_menu_resources` stops reading the channel after that, so a channel that closes after `Done` is no longer treated as a failure. This also covers the `Ok(None)` handoff path. - A loader that really panics now has its panic payload in the error (`resource loader stopped before finishing: <message>`). The pack-reload join's `"resource loader panicked"` gets the payload too. - `run()` checks for `horizon-resources.json` (the prepared-files manifest that `Assets::load` reads first) before any window, Discord presence or loader starts. If it is missing, the error names the absolute folder it looked in and says how to get the files: start from the launcher, run `horizon-prepare --prepare`, or pass `--resources`. ## Vanilla reference Horizon-only: this is Horizon's startup and error reporting, and vanilla has no prepared-resources step. No parity harness applies. ## Tests New tests: - `startup_menu::tests::a_failed_generation_keeps_its_error_after_the_loader_ends` - `startup_menu::tests::a_panicking_loader_reports_its_panic` - `startup_cpu_tests::a_folder_without_prepared_files_is_named_before_loading` The existing `disconnected_core_worker_is_reported_instead_of_waiting_forever` still passes. Before (only the code reverted, tests kept): ``` test game::startup_cpu_tests::a_folder_without_prepared_files_is_named_before_loading ... FAILED test game::startup_menu::tests::a_failed_generation_keeps_its_error_after_the_loader_ends ... FAILED called `Result::unwrap()` on an `Err` value: "resource loader stopped before finishing" test game::startup_menu::tests::a_panicking_loader_reports_its_panic ... FAILED left: "resource loader stopped before finishing" right: "resource loader stopped before finishing: atlas has no fonts" test result: FAILED. 4 passed; 3 failed ``` After: ``` test game::startup_cpu_tests::a_folder_without_prepared_files_is_named_before_loading ... ok test game::startup_menu::tests::a_failed_generation_keeps_its_error_after_the_loader_ends ... ok test game::startup_menu::tests::a_panicking_loader_reports_its_panic ... ok test game::startup_menu::tests::disconnected_core_worker_is_reported_instead_of_waiting_forever ... ok test game::startup_menu::tests::menu_is_usable_while_the_core_worker_is_blocked ... ok test game::startup_menu::tests::queued_server_keeps_address_and_player_identity ... ok test game::startup_cpu_tests::worker_prepares_owned_models_and_inventory_before_handoff ... ok test result: ok. 7 passed; 0 failed ``` ## In game (Windows 11) - **Before**: `horizon-client.exe` started from an empty folder (no `.local`) gave the same log as the issue: `title panorama unavailable (os error 3)`, `UI bundle ready`, `loading the title artwork`, then `resource loader stopped before finishing` and a crash report with only that line. A folder with a stale `horizon-resources.json` (wrong `data_version`) gave the same message. - **After**, empty folder: the game exits before opening a window, and the log and crash report say: `Horizon's prepared game files are missing: no horizon-resources.json in <absolute folder>\.local\horizon-client\26.3` / `Start Horizon from the Horizon launcher, which downloads and prepares them, or prepare them with: horizon-prepare --prepare (or pass --resources <folder>)`. - **After**, stale folder: the report now gives the real cause: `resources do not match Horizon's pinned data version` / `Prepare resources with the launcher, or: horizon-prepare --prepare`. - **After**, with real prepared resources: a normal launch through `horizon-ctl launch` still reaches the world (creative, standing on grass, screenshot taken), so a successful load is unchanged. ## Self-check `tools/pr_ready.py` doesn't run on Windows, so I ran its steps by hand: ``` cargo fmt --all -- --check # ok cargo clippy --profile fast -p horizon-client --features mods --all-targets -- -D warnings # ok cargo test --profile fast -p horizon-client --features mods --bin horizon-client -- startup_menu:: startup_cpu_tests:: # 7 passed cargo build --profile fast -p horizon-client --features mods --bins # ok ``` 🤖 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 05:10:23 +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#5121
No description provided.