tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] WebviewWindow::set_fullscreen in event handler freezes app [v2]

Open tjol opened this issue 4 months ago • 2 comments

Describe the bug

When I call set_fullscreen in an event handler (registered using app.listen_any), the window decorations vanish and then the app freezes. set_fullscreen never returns.

This is using Tauri v2.0.1 on Windows. The equivalent code worked in v1.6 (I found the issue during migration)

Reproduction

See the minimal app in this repo: https://github.com/tjol/tauri-v2-bug-fullscreen-freezes

lib.rs sets up this simple event listener:

    tauri::Builder::default()
        .plugin(tauri_plugin_shell::init())
        .setup(|app| {
            let main_window = app.get_webview_window("main").unwrap();
            app.listen_any("toggle-fullscreen", move |_| {
                let is_fullscreen = main_window.is_fullscreen().unwrap();
                println!("toggle fullscreen  (current: {is_fullscreen})");
                main_window.set_fullscreen(!is_fullscreen).unwrap();
                println!("is_fullscreen: {} -> {}", is_fullscreen, main_window.is_fullscreen().unwrap());
            });

            Ok(())
        })
        .run(tauri::generate_context!())
        .expect("error while running tauri application");

and the front-end sends the event "toggle-fullscreen".

The first println! call shows up in the console; the second println! call does not, indicating that set_fullscreen never returns

Expected behavior

set_fullscreen returns, and the window goes fullscreen.

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22631 x86_64 (X64)
    ✔ WebView2: 129.0.2792.79
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.80.1 (3f5fd8dd4 2024-08-06)
    ✔ cargo: 1.80.1 (376290515 2024-07-16)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
    - node: 20.14.0
    - pnpm: 9.2.0
    - npm: 10.7.0

[-] Packages
    - tauri 🦀: 2.0.1
    - tauri-build 🦀: 2.0.1
    - wry 🦀: 0.44.1
    - tao 🦀: 0.30.3
    - tauri-cli 🦀: 2.0.1

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.1

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../src

Stack trace

No response

Additional context

No response

tjol avatar Oct 07 '24 15:10 tjol