Repository navigation
fix(window): a resize exceeding max_texture_dimension_2d keeps the previous drawable and viewport, and initial surfaces clamp to the limit - #1449
Merged
Conversation
…evious drawable and viewport, and initial surfaces clamp to the limit
This was referenced Nov 23, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #306
Root cause
u16inWM_SIZE(for example65527for-9) or tou32fromGetClientRect(window.inner_size()).Surface::configureis wrapped in error scopes (crates/rune/src/window/surface/configure.rs),Win::resize_surface(crates/rune/src/window/surface/win.rs) and the resize/scale handlers (crates/rune/src/window/host/events.rs) still accepted sizes exceedingmax_texture_dimension_2d: overwritingWin::config, markingsurface_ok = false(forcing surface teardown andHost::reattach), resizingAlphaSurfaceto the bogus extent, setting the runtime viewport to 65527 px, and attempting a ~303 MB DIB allocation during Windows CPU boot (crates/rune/src/window/win32/cpu_frame.rs).crates/rune/src/window/surface.rs,crates/rune/src/window/host/create.rs,crates/rune/src/window/win32/handover.rs) passed rawinner_size()without clamping to the texture limit.Changes
drawable_size,max_surface_dim, andCPU_MAX_SURFACE_DIM(16_384) incrates/rune/src/window/surface.rs:Some(prev)): zero or out-of-range sizes (> max_dim) are ignored, keeping the previous valid size (clamped tomax_dimon reattach if a new device has a smaller limit).None): clamped to1..=max_dim, including insidesurface_config.Win::resize_surface(crates/rune/src/window/surface/win.rs) to validate throughdrawable_sizeandmax_surface_dim.WindowEvent::Resized,WindowEvent::Moved, andWindowEvent::ScaleFactorChanged(crates/rune/src/window/host/events.rs) plusHost::try_create,Host::reattach(crates/rune/src/window/host/create.rs),Host::open_on_cpu(crates/rune/src/window/win32/cpu_frame.rs), andhandover::prepare(crates/rune/src/window/win32/handover.rs) to clamp initial sizes and derive the runtime viewport from the acceptedconfigdimensions.window::tests::a_drawable_never_takes_a_size_exceeding_the_texture_limitincrates/rune/src/window/tests.rsand a changelog fragment inchangelog/unreleased/2026-11-23-wrapped-resize-height.md.Verification
window::tests::a_drawable_never_takes_a_size_exceeding_the_texture_limitfailed before the fix and passed after:cargo test -p rune -p rune-mermaid -p rune-kit --features rune-kit/markdown,rune-kit/mermaid a_drawable_never_takes_a_size_exceeding_the_texture_limit(1 passed)cargo test -p rune -p rune-mermaid -p rune-kit --features rune-kit/markdown,rune-kit/mermaid window::(108 passed)scripts/file-size.sh(0 errors)SetWindowPosGUI reproduction (no desktop window tests run here) and non-Windows target builds (only shared and Windows code changed).