Skip to content

Windows: Surface::configure panics when a resize reports a wrapped negative height #306

Closed

Description

@jeremielumandong

Rune rev: 4ca6835 · Platform: Windows 11, DX12 (seen under WARP, likely any adapter)

What happens

If the window is resized right after it appears (for example by SetWindowPos to 1172x777), the main thread sometimes panics:

wgpu error: Validation Error
In Surface::configure
  Requested was (1156, 65527)

The height 65527 is a negative client height wrapped to u16. It reproduced in 3 of about 8 attempts, at 829x550 just after launch and when shrinking 1658x1099 to 1172x777.

Expected

A bogus size from the platform should never take the app down.

Possible solution

In the drawable-size calculation (window.rs drawable_size) and the Windows resize path, ignore any size whose edge exceeds device.limits().max_texture_dimension_2d (or is 0). Keep the previous drawable until a sane size arrives, and clamp a window created at such a size to the largest the device takes.

After this change, 8 of 8 attempts survived. Reference commit: df25377 on the fork (see a_drawable_never_takes_a_size_that_wrapped_below_zero in window/tests.rs).

Reference implementation: https://github.com/jeremielumandong/rune/tree/software-rendering (based on 4ca6835).

Activity

  1. Hona commented on Nov 23, 2026

    @Hona
    Member

    Windows resize events and client-size queries can transiently wrap a negative client height to u16 (like 65527) or u32, which bypassed texture-limit checks, invalidated the surface, stretched the viewport, and oversized the CPU boot buffer. Fixed on dev in #1449 (ee4e99b7): resizes outside 1..=max_texture_dimension_2d now keep the previous drawable and viewport, and initial surface creation and reattach clamp to the limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions