[PR #3437] [MERGED] Window: a size above the GPU's largest texture no longer crashes #4976

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

📋 Pull Request Information

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

Base: main ← Head: fix-resize-absurd-size


📝 Commits (1)

  • 14a4d27 Window: a size above the GPU's largest texture no longer crashes

📊 Changes

1 file changed (+38 additions, -5 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx.rs (+38 -5)

📄 Description

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

What and why

Sizing the game's window past the GPU's largest texture crashed it. On Windows, SetWindowPos can make a window up to 65535 pixels tall. On v0.2.94, a 1000-wide window that tall has a 984x65496 client area, and winit reports it as is in WindowEvent::Resized. Renderer::resize passed it to Surface::configure, and wgpu panics:

In Surface::configure
  `Surface` width and height must be within the maximum supported texture size.
  Requested was (984, 65496), maximum extent for either dimension is 32768.

The change, all in crates/horizon-client-render/src/gfx.rs (horizon_client::gfx, re-exported):

  • New drawable_size(width, height, max): each side from 1 to the device's max_texture_dimension_2d.
  • Renderer::resize used to suspend drawing only for a 0 side (a minimized window). It now does the same for any size drawable_size rejects: it keeps the last surface size and draws nothing until the next Resized with a size it can use. Before this PR, minimizing worked this way and nothing else did.
  • Renderer::new clamps its first surface size to 1..=max_texture_dimension_2d, where it used .max(1). It also starts suspended for a size that drawable_size rejects.

All three Resized handlers (game.rs ×2, game/startup_menu.rs) go through Renderer::resize, and the game has no ScaleFactorChanged handler. Every render target (depth, offscreen, HDR, pack post, screenshots) is sized from Renderer::config, so none of them can see such a size now.

Vanilla reference

com.mojang.blaze3d.platform.Window.onFramebufferResize(int, int) (26.3, javap -c -p) starts with if (width <= 0 || height <= 0) return;. It keeps the last framebuffer size for a size it can't use, and this PR does the same. Vanilla has no explicit upper bound. Horizon needs one because wgpu validates the swapchain size against the device limit.

No harness: this is window and swapchain handling. The new unit test gfx::tests::drawable_size_skips_minimized_and_oversized_windows covers 0 on each side, exactly the limit, one past it, the crash's 984x65496 at 32768, and u32::MAX.

Real window, Windows 11, RTX 5080 (Vulkan), --world X --creative in a scratch HORIZON_HOME. One build of origin/main at 142388e1c, then the same tree with this commit (--profile fast). A PowerShell script called SetWindowPos(hwnd, 0, 100, 100, 1000, H, SWP_NOZORDER) on the game's window:

H GetClientRect after game
before 4856176 — panics: Surface::configure … Requested was (984, 65496), maximum … 32768 (crash report written)
after 4856176 984x65496 (window 1000x65535) alive
after 100000 984x65496 alive
after 0 984x0 alive (already handled as minimized)
after 700 984x661 alive, draws the world normally at 984x661, no crash report

Self-check

tools/pr_ready.py was not run. Checks run by hand (Windows 11, CARGO_TARGET_DIR outside the tree):

Check Result
cargo fmt --all -- --check ok
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings ok
cargo test -p horizon-client-render --lib gfx:: 97 passed, 0 failed, 6 ignored (GPU-only)

Rebased on main after #3186 (the crate split moved gfx.rs into horizon-client-render) and re-run on Windows 11: 97 passed, 0 failed, 6 ignored; drawable_size_skips_minimized_and_oversized_windows passes at its new location; cargo clippy -p horizon-client-render --all-targets -- -D warnings is clean.

🤖 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/3437 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-resize-absurd-size` --- ### 📝 Commits (1) - [`14a4d27`](https://github.com/horizon-rust/horizon/commit/14a4d2726d992371dfad2041a726b291c2ca2a6d) Window: a size above the GPU's largest texture no longer crashes ### 📊 Changes **1 file changed** (+38 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx.rs` (+38 -5) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Sizing the game's window past the GPU's largest texture crashed it. On Windows, `SetWindowPos` can make a window up to 65535 pixels tall. On v0.2.94, a 1000-wide window that tall has a 984x65496 client area, and winit reports it as is in `WindowEvent::Resized`. `Renderer::resize` passed it to `Surface::configure`, and wgpu panics: ``` In Surface::configure `Surface` width and height must be within the maximum supported texture size. Requested was (984, 65496), maximum extent for either dimension is 32768. ``` The change, all in `crates/horizon-client-render/src/gfx.rs` (`horizon_client::gfx`, re-exported): - New `drawable_size(width, height, max)`: each side from 1 to the device's `max_texture_dimension_2d`. - `Renderer::resize` used to suspend drawing only for a 0 side (a minimized window). It now does the same for any size `drawable_size` rejects: it keeps the last surface size and draws nothing until the next `Resized` with a size it can use. Before this PR, minimizing worked this way and nothing else did. - `Renderer::new` clamps its first surface size to `1..=max_texture_dimension_2d`, where it used `.max(1)`. It also starts suspended for a size that `drawable_size` rejects. All three `Resized` handlers (`game.rs` ×2, `game/startup_menu.rs`) go through `Renderer::resize`, and the game has no `ScaleFactorChanged` handler. Every render target (depth, offscreen, HDR, pack post, screenshots) is sized from `Renderer::config`, so none of them can see such a size now. ## Vanilla reference `com.mojang.blaze3d.platform.Window.onFramebufferResize(int, int)` (26.3, `javap -c -p`) starts with `if (width <= 0 || height <= 0) return;`. It keeps the last framebuffer size for a size it can't use, and this PR does the same. Vanilla has no explicit upper bound. Horizon needs one because wgpu validates the swapchain size against the device limit. No harness: this is window and swapchain handling. The new unit test `gfx::tests::drawable_size_skips_minimized_and_oversized_windows` covers 0 on each side, exactly the limit, one past it, the crash's 984x65496 at 32768, and `u32::MAX`. **Real window, Windows 11, RTX 5080 (Vulkan), `--world X --creative` in a scratch `HORIZON_HOME`.** One build of `origin/main` at 142388e1c, then the same tree with this commit (`--profile fast`). A PowerShell script called `SetWindowPos(hwnd, 0, 100, 100, 1000, H, SWP_NOZORDER)` on the game's window: | | H | `GetClientRect` after | game | |---|---|---|---| | before | 4856176 | — | panics: `Surface::configure` … `Requested was (984, 65496), maximum … 32768` (crash report written) | | after | 4856176 | 984x65496 (window 1000x65535) | alive | | after | 100000 | 984x65496 | alive | | after | 0 | 984x0 | alive (already handled as minimized) | | after | 700 | 984x661 | alive, draws the world normally at 984x661, no crash report | ## Self-check `tools/pr_ready.py` was not run. Checks run by hand (Windows 11, CARGO_TARGET_DIR outside the tree): | Check | Result | | --- | --- | | `cargo fmt --all -- --check` | ok | | `cargo clippy -p horizon-client --features mods --all-targets -- -D warnings` | ok | | `cargo test -p horizon-client-render --lib gfx::` | 97 passed, 0 failed, 6 ignored (GPU-only) | **Rebased on main after #3186** (the crate split moved `gfx.rs` into horizon-client-render) and re-run on Windows 11: 97 passed, 0 failed, 6 ignored; `drawable_size_skips_minimized_and_oversized_windows` passes at its new location; `cargo clippy -p horizon-client-render --all-targets -- -D warnings` is clean. 🤖 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:09:19 +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#4976
No description provided.