fix(runtime-wry): clamp window size dimensions to i32::MAX - #15899
Open
tachsin wants to merge 1 commit into
Open
fix(runtime-wry): clamp window size dimensions to i32::MAX#15899tachsin wants to merge 1 commit into
tachsin wants to merge 1 commit into
Conversation
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.
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.
Summary
Fixes #15648.
Setting a window's
width/height(orminWidth/minHeight/maxWidth/maxHeight) abovei32::MAX(e.g.2147483648) intauri.conf.jsoncrashes the whole app on startup instead of failing gracefully.I reproduced this locally on macOS using the
helloworldexample withwidthset to2147483648. The failure is a non-unwinding panic:Running under
lldb, the console shows the actual native failure right before the abort:So the oversized width reaches AppKit's
NSWindowframe validation and fails there, and because this all happens inside theapplicationDidFinishLaunching:→tao::...::did_finish_launchingcallback 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-wryclamps or validates these dimensions before handing them to tao/AppKit — an out-of-range config value goes straight through unchecked.Fix
Clamp
width/heightand the min/max size constraints toi32::MAXinWindowBuilderWrapper(crates/tauri-runtime-wry/src/lib.rs) before they're handed to tao, in both theinner_size/min_inner_size/max_inner_sizebuilder methods and thewith_configconstraints setup. This covers both thetauri.conf.jsonpath and direct use of the Rust builder APIs.Test plan
helloworldexample (width: 2147483648) before the fixcargo check -p tauri-runtime-wrycargo clippy -p tauri-runtime-wry— no new warnings