tauri-apps / tauri

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

[bug] Can't debug rust backend on windows 11 #6875

Closed Andy-Zi closed 1 year ago

Andy-Zi commented 1 year ago

Describe the bug

On Windows, when following the steps outlined in the documentation for create-tauri-app (https://tauri.app/v1/guides/getting-started/setup/) and how to debug under Windows in vsCode (https://tauri.app/v1/guides/debugging/vs-code) it is not possible to debug the rust backend.

Reproduction

Expected behavior

The rust backend should not panic on a default project

Platform and versions

[✔] Environment
    - OS: Windows 10.0.22621 X64
    ✔ WebView2: 112.0.1722.68
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.69.0 (84c898d65 2023-04-16)
    ✔ Cargo: 1.69.0 (6e9a83356 2023-04-12)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 18.16.0
    - yarn: 1.22.19
    - npm: 9.6.5

[-] Packages
    - tauri [RUST]: 1.3.0
    - tauri-build [RUST]: 1.3.0
    - wry [RUST]: 0.24.1
    - tao [RUST]: 0.16.0
    - @tauri-apps/api [NPM]: 1.3.0
    - @tauri-apps/cli [NPM]: 1.3.0

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:1420/
    - framework: React
    - bundler: Vite

Stack trace

thread 'main' panicked at 'error while running tauri application: Runtime(CreateWebview(WebView2Error(WindowsError(Error { code: 0x80070057, message: The parameter is incorrect. }))))', src\main.rs:23:6
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library\std\src\panicking.rs:579
   1: core::panicking::panic_fmt
             at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library\core\src\panicking.rs:64
   2: core::result::unwrap_failed
             at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library\core\src\result.rs:1750
   3: enum2$<core::result::Result<tuple$<>,enum2$<tauri::error::Error> > >::expect<tuple$<>,enum2$<tauri::error::Error> >
             at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc\library\core\src\result.rs:1047
   4: address_manager::main
             at .\src\main.rs:17
   5: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc\library\core\src\ops\function.rs:250
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Additional context

The bug is not present on linux.

amrbashir commented 1 year ago

This sounds like you're missing a Webview2 installation. could you make sure webview2 is installed? or re-install from https://developer.microsoft.com/en-us/microsoft-edge/webview2/

Andy-Zi commented 1 year ago

As the documentation points out (https://tauri.app/v1/guides/getting-started/prerequisites/) it should have been installed by default and when trying to reinstall i get the following error saing it is already installed.

image

I can run Tauri apps just fine, if i don't start the debugger.

LLukas22 commented 1 year ago

I'm experiencing the exact same issue and haven't found a workaround until now. I also have the webview installed and can run tauri apps normaly. I can even set a breakpoint in the main function which will be hit, but as soon as the builders run function is called rust panics.

amrbashir commented 1 year ago

I still can't reproduce it on latest Windows 11 with latest webview2 runtime.

LLukas22 commented 1 year ago

Alright im gonna reinstall the latest windows 11 when i get back home from work and will let you know if it works.

Andy-Zi commented 1 year ago

After a complete reinstall of windows i got it working

spieglt commented 1 year ago

I'm experiencing this on Windows 10 and Windows 11. cargo tauri dev and cargo tauri build work fine, but debugging fails whether I follow the official instructions or just make a simple LLDB launch configuration pointing to an .exe built with cargo tauri build --debug.

Andy-Zi commented 1 year ago

My biggest hypothesis is that i broke something in edge while trying to debloat my windows installation. @spieglt Did you use any windows debloater software?

spieglt commented 1 year ago

No. Edge works fine, and Tauri works fine, I just can't debug. It fails when the Builder's run function is hit like @LLukas22 described. The fact that this is happening to several people in the past month makes me suspect something changed with Tauri but I'm not sure.

LLukas22 commented 1 year ago

@spieglt After a windows 11 reinstall it worked as expected, maybe something is wrong with old windows images?

spieglt commented 1 year ago

I doubt it, personally.

liuhuapiaoyuan commented 1 year ago

i hava the same error!