Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/invoke-handler-stack-overflow-on-debug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
tauri: patch:bug
---

Fix large number of commands with large structs as parameters causing stack overflow on debug build on Windows
31 changes: 19 additions & 12 deletions crates/tauri-macros/src/command/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,18 +280,25 @@ pub fn wrapper(attributes: TokenStream, item: TokenStream) -> TokenStream {
#maybe_macro_export
#[doc(hidden)]
macro_rules! #wrapper {
// double braces because the item is expected to be a block expression
($path:path, $invoke:ident) => {{
#[allow(unused_imports)]
use #root::ipc::private::*;
// prevent warnings when the body is a `compile_error!` or if the command has no arguments
#[allow(unused_variables)]
let #root::ipc::Invoke { message: #message, resolver: #resolver, acl: #acl } = $invoke;

#maybe_span

#body
}};
// double braces because the item is expected to be a block expression
($path:path, $invoke:ident) => {
// The IIFE here is for preventing stack overflow on Windows debug build,
// see https://github.com/tauri-apps/tauri/issues/12488
{
#[cfg_attr(not(debug_assertions), inline(always))]
move || {
Copy link
Member

Choose a reason for hiding this comment

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

ohh so nice that Rust optimizes this for us on release ❤️ awesome idea

#[allow(unused_imports)]
use #root::ipc::private::*;
// prevent warnings when the body is a `compile_error!` or if the command has no arguments
#[allow(unused_variables)]
let #root::ipc::Invoke { message: #message, resolver: #resolver, acl: #acl } = $invoke;

#maybe_span

#body
}
}()
};
}

// allow the macro to be resolved with the same path as the command function
Expand Down
Loading