marc2332 / freya

Cross-platform GUI library for 🦀 Rust powered by 🧬 Dioxus and 🎨 Skia.
https://freyaui.dev/
MIT License
1.33k stars 51 forks source link

bug: App gets frozen when using a custom Tokio runtime #779

Closed reyamir closed 1 month ago

reyamir commented 1 month ago

Description: Add custom-tokio-rt to Cargo features. Then create simple app:

#[tokio::main]
async fn main() {
    launch_with_title(|| rsx!(label { "Hello, World!" }), "Custom Tokio Runtime")
}

And run app like normally, after few seconds CPU usage will spike to very high cause app hang forever.

Reprocedue repo: https://github.com/reyamir/macos-app-stuck

Screenshot 2024-07-11 at 15 42 59
marc2332 commented 1 month ago

Seems to also affect Linux, but not Windows

marc2332 commented 1 month ago

Can you try with:

fn main() {
    let rt = tokio::runtime::Builder::new_multi_thread()
    .enable_all()
    .build()
    .unwrap();
    let _guard = rt.enter();
    launch_with_title(|| rsx!(label { "Hello, World!" }), "Custom Tokio Runtime")
}
reyamir commented 1 month ago

It still stuck after few seconds

reyamir commented 1 month ago

Oh sorry, I still use #[tokio::main] and async fn main I've updated my code exactly like you, and it work fine now.

marc2332 commented 1 month ago

Nice, just fixed the example in https://github.com/marc2332/freya/commit/ef35ad266d324325c5af95226eca819c912ac545