tauri-apps / plugins-workspace

All of the official Tauri plugins in one place!
https://tauri.app
Apache License 2.0
811 stars 224 forks source link

[log] process hang and never open the window if add dep `tokio` with `signal` feature #307

Open meowtec opened 1 year ago

meowtec commented 1 year ago

platform

Linux / macOS, but not Windows

reproduction

https://github.com/meowtec/bug-reproductions/tree/tauri-log the branch is tauri-log

  1. usetauri-plugin-log
  2. add dependence tokio with the signal feature
  3. add some log in setup() hook
  4. npm run tauri dev

main.rs

fn main() {
    tauri::Builder::default()
        .plugin(
            tauri_plugin_log::Builder::default()
                .targets([LogTarget::LogDir, LogTarget::Stdout, LogTarget::Webview])
                .build(),
        )
        .setup(move |_app| {
            // NOTICE: use log here!!!
            log::info!("setup app");
            Ok(())
        })
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Cargo.toml

[dependencies]
tauri = { version = "1.2", features = ["shell-open"] }
log = "0.4"
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }

# NOTICE: add tokio!!!!
tokio = { version = "1", features = ["signal"] }

The window will never show.

The output:

> tauri-app-demo@0.0.0 tauri
> tauri dev

        Info Watching /bugs-report/src-tauri for changes...
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
Could not determine the accessibility bus address
[2023-04-15][14:21:50][tauri_app][INFO] setup app
[2023-04-15][14:21:50][mio::poll][TRACE] registering event source with poller: token=Token(2147483649), interests=READABLE
FabianLars commented 1 year ago

/upstream tauri-apps/tauri

This seems to concern tauri's event system (or at least emit) in general, not just the plugin. Let's see if our github bot works in this repo too :D

yuezk commented 1 year ago

I met the same problem and removing LogTarget::Webview worked for me.

meowtec commented 1 year ago

I met the same problem and removing LogTarget::Webview worked for me.

Yes, this workaround worked for me too.

Lurrobert commented 4 months ago

Thats a pretty weird bug. Just faced it myself. Any reason why this happens? I guess the docs must be updated for this case so that others can fix it themselves