Skip to content

fix(runtime): clamp oversized window dimensions (fix #15648)#15649

Open
justjavac wants to merge 2 commits into
tauri-apps:devfrom
justjavac:fix/15648-clamp-window-dimensions
Open

fix(runtime): clamp oversized window dimensions (fix #15648)#15649
justjavac wants to merge 2 commits into
tauri-apps:devfrom
justjavac:fix/15648-clamp-window-dimensions

Conversation

@justjavac

Copy link
Copy Markdown
Contributor

What changed

  • Clamp initial window width and height before passing them to the WRY window builder.
  • Add a patch changeset for tauri-runtime-wry.

Closes #15648.

Testing

  • cargo fmt -p tauri-runtime-wry
  • cargo check -p tauri-runtime-wry
  • git diff --check

@justjavac justjavac requested a review from a team as a code owner July 4, 2026 10:04
@justjavac justjavac force-pushed the fix/15648-clamp-window-dimensions branch from d79e09c to 56fd19b Compare July 5, 2026 03:35
@justjavac justjavac force-pushed the fix/15648-clamp-window-dimensions branch from 56fd19b to 7783bb8 Compare July 5, 2026 03:39
Comment thread crates/tauri-runtime-wry/src/lib.rs Outdated

fn inner_size(mut self, width: f64, height: f64) -> Self {
self.inner = self.inner.with_inner_size(LogicalSize::new(width, height));
self.inner = self.inner.with_inner_size(LogicalSize::new(

@Legend-Master Legend-Master Jul 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to know where exactly crashed and fixing that instead of clamping the values here (there're another bug and this just makes it harder to find)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated in aed6a5d.

I moved the clamp out of WindowBuilderWrapper::inner_size; that builder method now preserves the caller-provided size. The size is now capped only on macOS immediately before creating the window, using the monitor scale factor and capping the physical initial size to i32::MAX. This is the path that feeds tao/AppKit window creation instead of clamping every builder input.

Validation I ran:

  • Reproduced the original crash on an unpatched checkout by setting examples/helloworld width to 2147483648 and running RUST_BACKTRACE=full cargo run -p tauri --example helloworld. It aborts with panic in a function that cannot unwind, at tao::platform_impl::platform::app_delegate::did_finish_launching.
  • Ran the same oversized config on this branch; the app entered the event loop with no panic, then I stopped it manually.
  • Added unit coverage that inner_size preserves oversized input, safe macOS values are left unchanged, oversized values are capped, and scale factor is accounted for.
  • cargo fmt --check
  • cargo test -p tauri-runtime-wry --lib
  • cargo check -p tauri-runtime-wry
  • git diff --check

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds like a tao issue to me? We should probably fix it there

@justjavac

Copy link
Copy Markdown
Contributor Author

Moved the fix upstream to tao as suggested: tauri-apps/tao#1259.

The tao PR clamps oversized macOS initial inner window dimensions before constructing the native NSWindow, and uses the same clamped value for tao's initial inner_rect.

Validation run on the tao branch:

  • cargo fmt --check (passes; only existing imports_granularity nightly warnings)
  • cargo test initial_inner_size --lib
  • cargo test --lib
  • cargo check (passes with existing warnings)
  • git diff --check

Earlier Tauri-side reproduction: setting the helloworld example width to 2147483648 reproduced the macOS abort during did_finish_launching; applying this clamp before native window creation allowed the app to enter the event loop.

@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 Jul 7, 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