tauri-apps / tauri

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

[bug] The Quick-start project cannot be started and the window flashes back. #11316

Closed yancy-hong closed 1 month ago

yancy-hong commented 1 month ago

Describe the bug

Hi, I am a newbie to Tauri. According to the quick-start tutorial on the Tauri official website, I created a project. However, the window flashed back when it was started.

Reproduction

Partial logs:

PS F:\project\rust-projects\test> npm create tauri-app@latest
Need to install the following packages:
  create-tauri-app@4.5.1
Ok to proceed? (y) y
✔ Project name · test
✔ Identifier · com.test.app
✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, bun)
✔ Choose your package manager · npm
✔ Choose your UI template · Vanilla
✔ Choose your UI flavor · TypeScript

Template created! To get started run:
  cd test
  npm install
  npm run tauri android init

For Desktop development, run:
  npm run tauri dev

For Android development, run:
  npm run tauri android dev

PS F:\project\rust-projects> cd .\test\
PS F:\project\rust-projects\test> npm install

added 15 packages, and audited 16 packages in 1s

5 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
PS F:\project\rust-projects\test> npm run tauri dev

...

Compiling webview2-com v0.33.0
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 44.04s

GIF effect picture: flash_back

Expected behavior

The window has been successfully launched.

Full tauri info output

PS F:\project\rust-projects\tauri-test> cargo tauri info

[✔] Environment
    - OS: Windows 10.0.22631 x86_64 (X64)
    ✔ WebView2: 121.0.2277.83
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.81.0 (eeb90cda1 2024-09-04)
    ✔ cargo: 1.81.0 (2dbb1af80 2024-08-20)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
    - node: 18.16.1
    - npm: 9.5.1

[-] Packages
    - tauri 🦀: 2.0.2
    - tauri-build 🦀: 2.0.1
    - wry 🦀: 0.44.1
    - tao 🦀: 0.30.3
    - tauri-cli 🦀: 2.0.2
    - @tauri-apps/api : 2.0.2
    - @tauri-apps/cli : 2.0.2 (outdated, latest: 2.0.3)

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.1
    - @tauri-apps/plugin-shell : 2.0.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite

Stack trace

No response

Additional context

OS: Windows11

yancy-hong commented 1 month ago

I have also tried to use Cargo to initialize the project:

PS F:\project\rust-projects> cargo install create-tauri-app --locked
    Updating crates.io index
     Ignored package `create-tauri-app v4.5.1` is already installed, use --force to override
PS F:\project\rust-projects> cargo create-tauri-app
✔ Project name · test
✔ Identifier · com.test.app
✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, bun)
✔ Choose your package manager · npm
✔ Choose your UI template · Vanilla
✔ Choose your UI flavor · JavaScript

Template created! To get started run:
  cd test
  npm install
  npm run tauri android init

For Desktop development, run:
  npm run tauri dev

For Android development, run:
  npm run tauri android dev

PS F:\project\rust-projects> cd .\test\
PS F:\project\rust-projects\test> cargo tauri dev
    Running BeforeDevCommand (`npm run dev`)

> test@0.1.0 dev
> vite

  VITE v5.4.8  ready in 208 ms

  ➜  Local:   http://localhost:1420/
    Info Watching F:\project\rust-projects\test\src-tauri for changes...
   Compiling test v0.1.0 (F:\project\rust-projects\test\src-tauri)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 6.06s

Similarly, the project still flashes back when started.

yancy-hong commented 1 month ago

So I no longer insist on using the cargo tauri dev or npm run tauri dev command to start the project. After executing the command:

cargo install create-tauri-app --locked
cargo create-tauri-app

I tried to use the IDE RustRover to start the project. The following error is reported in the IDE's console:

cargo.exe run --color=always --package tauri-test --bin tauri-test
    Finished dev profile [unoptimized + debuginfo] target(s) in 0.23s
     Running target\debug\tauri-test.exe
error: process didn't exit successfully: target\debug\tauri-test.exe (exit code: 0x80000003)

image

Is there something I did wrong?

FabianLars commented 1 month ago

Can you please also include the output of cargo tauri info as required by the issue template? Thanks.

yancy-hong commented 1 month ago

Sorry. The issue template content has been updated at the place of 'Full tauri info output' above. At the same time, I have also added a failed GIF image at the place of 'Reproduction'.

FabianLars commented 1 month ago

Hmm, looks like it's failing to start the webview. Can you try Windows Settings -> Apps -> Microsoft Edge WebView2 -> Change -> Repair?

yancy-hong commented 1 month ago

Success! Tauri is working! I found that my previous WebView2 version was 121.0.2277.83. Now, after updating it to 129.0.2792.89, Tauri has been successfully started. Thank you for your help.