Skip to content

fix(runtime-wry): clamp window size dimensions to i32::MAX - #15899

Open
tachsin wants to merge 1 commit into
tauri-apps:devfrom
tachsin:fix/window-size-overflow
Open

fix(runtime-wry): clamp window size dimensions to i32::MAX#15899
tachsin wants to merge 1 commit into
tauri-apps:devfrom
tachsin:fix/window-size-overflow

Conversation

@tachsin

@tachsin tachsin commented Aug 20, 2026

Copy link
Copy Markdown

Summary

Fixes #15648.

Setting a window's width/height (or minWidth/minHeight/maxWidth/maxHeight) above i32::MAX (e.g. 2147483648) in tauri.conf.json crashes the whole app on startup instead of failing gracefully.

I reproduced this locally on macOS using the helloworld example with width set to 2147483648. The failure is a non-unwinding panic:

thread 'main' panicked at core/src/panicking.rs:225:5:
panic in a function that cannot unwind
thread caused non-unwinding panic. aborting.

Running under lldb, the console shows the actual native failure right before the abort:

*** Assertion failure in void _NSWindowSetFrameIvar(NSWindow *, NSRect)(), NSWindow.m:1070

So the oversized width reaches AppKit's NSWindow frame validation and fails there, and because this all happens inside the applicationDidFinishLaunching:tao::...::did_finish_launching callback boundary, the resulting panic can't unwind across the FFI boundary and Rust aborts the process (which is also why the compiler discards the real panic message and reports the generic "cannot unwind" text instead of the original panic).

Nothing in tauri-runtime-wry clamps or validates these dimensions before handing them to tao/AppKit — an out-of-range config value goes straight through unchecked.

Fix

Clamp width/height and the min/max size constraints to i32::MAX in WindowBuilderWrapper (crates/tauri-runtime-wry/src/lib.rs) before they're handed to tao, in both the inner_size/min_inner_size/max_inner_size builder methods and the with_config constraints setup. This covers both the tauri.conf.json path and direct use of the Rust builder APIs.

Test plan

  • Reproduced the crash with the helloworld example (width: 2147483648) before the fix
  • Confirmed the same config no longer crashes after the fix (window creates successfully)
  • cargo check -p tauri-runtime-wry
  • cargo clippy -p tauri-runtime-wry — no new warnings

Setting a window's width/height (or min/max size constraints) above
i32::MAX in tauri.conf.json crashes the app on startup with a
non-unwinding panic instead of a catchable error. On macOS this
surfaces as an AppKit `NSWindow` frame assertion failure
(_NSWindowSetFrameIvar) deep inside the applicationDidFinishLaunching:
callback, which Rust cannot unwind across, so the whole process aborts.

Clamp these dimensions to i32::MAX before they reach the native
windowing APIs so an oversized config value degrades gracefully
instead of crashing the app.
@tachsin
tachsin requested a review from a team as a code owner August 20, 2026 07:24
@Legend-Master Legend-Master added the ai-slop Low effort content, see https://github.com/tauri-apps/tauri?tab=contributing-ov-file#ai-tool-policy label Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-slop Low effort content, see https://github.com/tauri-apps/tauri?tab=contributing-ov-file#ai-tool-policy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] panic in 'main' when tauri.conf.json app.window.width > i32 max value

2 participants