tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
81.85k stars 2.46k forks source link

[bug] create window after "await WebviewWindow.getByLabel" got error "thread 'main' has overflowed its stack" on windows #10692

Open songjiachao opened 3 weeks ago

songjiachao commented 3 weeks ago

Describe the bug

export const openFunProxy = async () => {
  let proxyWindow = await WebviewWindow.getByLabel('fun-proxy');
  if (proxyWindow) {
    const isMinimize = await proxyWindow?.isMinimized();
    if (isMinimize) proxyWindow?.unminimize();
  } else {
    // TODO 不加setTimeout windows上面会报错thread 'main' has overflowed its stack
    setTimeout(async()=>{
      await invoke('plugin:window-manager|create_proxy_window_cmd');
    },1000)
  }
};

// rust

#[tauri::command]
pub async fn create_proxy_window_cmd() -> Result<(), TauriError> {
    create_proxy_window();
    Ok(())
}
pub fn create_proxy_window() -> WebviewWindow {
    warn!("Proxy window not found, create new proxy window!");
    let app: &tauri::AppHandle<_> = APP.get().unwrap();
    let mut win_builder =
        WebviewWindowBuilder::new(app, "fun-proxy", WebviewUrl::App("/desktop/proxy".into()))
            .title("Funproxy: 一键切换环境,纵享丝滑抓包,全链路测试好帮手 🏅")
            .visible(true)
            .inner_size(1400., 860.)
            .center();

    // set_transparent_titlebar
    #[cfg(target_os = "macos")]
    {
        use tauri::TitleBarStyle;
        win_builder = win_builder
            .title_bar_style(TitleBarStyle::Overlay)
            .hidden_title(true);
    }

    #[cfg(target_os = "windows")]
    {
        win_builder = win_builder.decorations(false);
    }

 win_builder.build().unwrap()

}

Reproduction

No response

Expected behavior

No response

Full tauri info output

PS D:\My Documents\11091628\Desktop\code\fun-family\app\desktop> cargo tauri info

[✔] Environment
    - OS: Windows 10.0.22631 X64
    ✔ WebView2: 127.0.2651.105
    ✔ MSVC:
        - Visual Studio Community 2022
        - Visual Studio 生成工具 2022
    ✔ rustc: 1.79.0 (129f3b996 2024-06-10)
    ✔ cargo: 1.79.0 (ffa9cf99a 2024-06-03)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
    - node: 20.12.2
    - pnpm: 9.1.2
    - npm: 10.5.0

[-] Packages
    - tauri [RUST]: 2.0.0-rc.3
    - tauri-build [RUST]: 2.0.0-rc.3
    - wry [RUST]: 0.42.0
    - tao [RUST]: 0.29.0
    - tauri-cli [RUST]: 2.0.0-beta.14
    - @tauri-apps/api [NPM]: 2.0.0-rc.2
    - @tauri-apps/cli [NPM]: 2.0.0-beta.14

[-] App
    - build-type: bundle
    - CSP: default-src asset: https://asset.localhost blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
    - frontendDist: ../dist
    - devUrl: http://127.0.0.1:1420/
    - framework: React (Next.js)
    - bundler: Vite

Stack trace

No response

Additional context

No response

FabianLars commented 3 weeks ago

I don't see how this may be related, but can you try this suggestion? https://github.com/tauri-apps/tauri/issues/9882#issuecomment-2298569850