[PR #6705] [MERGED] Fall back instead of crashing when the scaled world runs out of video memory #7042

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

📋 Pull Request Information

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

Base: main ← Head: fix/resolution-scale-slider-crash


📝 Commits (1)

  • f9fb435 Fall back instead of crashing when the scaled world runs out of video memory

📊 Changes

1 file changed (+62 additions, -12 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx/world_post.rs (+62 -12)

📄 Description

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

Fixes #6607

Cause

Post::prepare (crates/horizon-client-render/src/gfx/world_post.rs) rebuilds the scaled world targets (colour, depth and, with TAA, two Rgba16Float history textures) whenever the size changes. It built the new targets while the old ones were still alive, and it did not catch a failed allocation. Dragging the Resolution Scale slider therefore briefly needs old + new, and on a 6 GB card with LOD data loaded the create_texture call hit wgpu error: Out of Memory, which wgpu's default handler turns into a panic. The crash report in the issue is exactly this (RTX 2060, render distance 24, high LOD distance, slider drag).

Fix

  • Drop the old target before building the new one.
  • Build inside an out-of-memory + validation error scope (a texture that failed to allocate is invalid, so its create_view raises a validation error too; an OOM-only scope still panics, which the test below caught).
  • On failure, log a warning and step the scale down by a quarter (floor 0.25), retrying; if even that fails, draw at the window's size.

Test

No automated test: wgpu cannot cap video memory, so a unit test cannot force an OOM. Manual, on an RTX 2060 (6 GB, Vulkan, NVIDIA 615.78.08), with the scale/size caps raised in throwaway builds of both sides (resolutionScale:2000, taa:true, 1280x720 offscreen via horizon-ctl, which asks for a 25600x14400 target):

  • Before (main + raised caps): panics, wgpu error: Out of Memory at wgpu_core.rs:1637, the same as the issue.
  • First version of this fix: still panicked (Texture with 'Scaled world depth' label is invalid in create_view), which is why the scope also catches validation errors.
  • After: no crash, screenshot succeeds. The log shows scale 20.00 -> 15.00 -> 11.25 -> 8.44 -> 6.33 and then the target fits.

The raised caps are not part of this PR.

Self-check

  • cargo fmt --all -- --check
  • cargo clippy -p horizon-client-render --lib -- -D warnings
  • cargo test -p horizon-client-render --lib world_post (3 passed)
  • python3 tools/port_ledger.py check --base origin/main exits 0 (notes prepare/build_target as long uncited fns; no vanilla counterpart)
  • tools/pr_ready.py not run: no ALSA headers on this machine
  • Not covered: the issue's exact LOD-heavy memory load, and other allocation sites on the scaled path (for example the order-independent-transparency targets).

🤖 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/6705 **Author:** [@ClickingMaster](https://github.com/ClickingMaster) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/resolution-scale-slider-crash` --- ### 📝 Commits (1) - [`f9fb435`](https://github.com/horizon-rust/horizon/commit/f9fb435f94d4db1b0aa1d94970eb2f94e2eaa859) Fall back instead of crashing when the scaled world runs out of video memory ### 📊 Changes **1 file changed** (+62 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx/world_post.rs` (+62 -12) </details> ### 📄 Description > 🤖 Opened by ClickingMaster's AI agent (Claude Code, Claude Sonnet 5.5), not by ClickingMaster personally. Fixes #6607 ## Cause `Post::prepare` (`crates/horizon-client-render/src/gfx/world_post.rs`) rebuilds the scaled world targets (colour, depth and, with TAA, two `Rgba16Float` history textures) whenever the size changes. It built the new targets while the old ones were still alive, and it did not catch a failed allocation. Dragging the Resolution Scale slider therefore briefly needs old + new, and on a 6 GB card with LOD data loaded the `create_texture` call hit `wgpu error: Out of Memory`, which wgpu's default handler turns into a panic. The crash report in the issue is exactly this (RTX 2060, render distance 24, high LOD distance, slider drag). ## Fix - Drop the old target before building the new one. - Build inside an out-of-memory + validation error scope (a texture that failed to allocate is invalid, so its `create_view` raises a validation error too; an OOM-only scope still panics, which the test below caught). - On failure, log a warning and step the scale down by a quarter (floor 0.25), retrying; if even that fails, draw at the window's size. ## Test No automated test: wgpu cannot cap video memory, so a unit test cannot force an OOM. Manual, on an RTX 2060 (6 GB, Vulkan, NVIDIA 615.78.08), with the scale/size caps raised in throwaway builds of both sides (`resolutionScale:2000`, `taa:true`, 1280x720 offscreen via `horizon-ctl`, which asks for a 25600x14400 target): - **Before (main + raised caps):** panics, `wgpu error: Out of Memory` at `wgpu_core.rs:1637`, the same as the issue. - **First version of this fix:** still panicked (`Texture with 'Scaled world depth' label is invalid` in `create_view`), which is why the scope also catches validation errors. - **After:** no crash, screenshot succeeds. The log shows `scale 20.00 -> 15.00 -> 11.25 -> 8.44 -> 6.33` and then the target fits. The raised caps are not part of this PR. ## Self-check - [x] `cargo fmt --all -- --check` - [x] `cargo clippy -p horizon-client-render --lib -- -D warnings` - [x] `cargo test -p horizon-client-render --lib world_post` (3 passed) - [x] `python3 tools/port_ledger.py check --base origin/main` exits 0 (notes `prepare`/`build_target` as long uncited fns; no vanilla counterpart) - [ ] `tools/pr_ready.py` not run: no ALSA headers on this machine - [ ] Not covered: the issue's exact LOD-heavy memory load, and other allocation sites on the scaled path (for example the order-independent-transparency targets). 🤖 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:32:38 +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#7042
No description provided.