Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insane gpu usage when hovering over the UI. #2119

Open
2 tasks done
FaisalAhmedAlghamdi opened this issue Oct 22, 2023 · 15 comments
Open
2 tasks done

Insane gpu usage when hovering over the UI. #2119

FaisalAhmedAlghamdi opened this issue Oct 22, 2023 · 15 comments
Labels
bug Something isn't working

Comments

@FaisalAhmedAlghamdi
Copy link

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • My hardware is compatible and my graphics drivers are up-to-date.

What happened?

image

As you can see when running the todo demo in debug or release and then i hover my mouse over the gui i get insane gpu usage for no reason.

What is the expected behavior?

Minimal GPU usage, this isn't an issue in desktop machines but its a huge problem for laptops since the battery will get drained quickly.

Version

crates.io release

Operating System

Windows

Do you have any log output?

No response

@FaisalAhmedAlghamdi FaisalAhmedAlghamdi added the bug Something isn't working label Oct 22, 2023
@anantnrg
Copy link

Instead of saying:

crates.io release

please specify the exact number, like 0.10.0 or if you built it from scratch, the commit hash, like 3ec5ad4.

@b4too
Copy link

b4too commented Nov 4, 2023

I get the same behavior from a build --release version of the tour example on an ubuntu-based distro with latest stable available nvidia driver(525.147.05), latest stable rust toolchain(1.73.0), and iced version 0.10.0.
Using nvidia-smi I see an increase in GPU usage from 0-1% when the mouse is outside the window to 30% when hovering over buttons, and ~20% when hovering over simple window. To compare, I only go to 5% while hovering over the nemo file explorer buttons.
tour_usage_gpu
Perhaps making an available API to reduce the calls frequency to user inputs (hover, click, ...) or something like that ? I only discovered the iced ecosystem and started playing with it, I like it a lot, but since my knowledge is limited I might not know of such an API if it already exists.

@mochalins
Copy link
Contributor

mochalins commented Jan 11, 2024

I'm not certain if this is related, but using the latest proprietary Nvidia driver (545.29.06-2) on Fedora 39 Wayland, with iced master branch (commit 90332ac), simply hovering the cursor over any of the examples causes the example to immediately hang. This behavior extends to multiple third party Iced applications that I could download and test from #355, and also to Iced 0.10.0. This is all on latest stable Rust toolchain (1.75.0).

Edit: This behavior was resolved on my system by forcing winit to use X11.

@salimp2009
Copy link

salimp2009 commented Jan 22, 2024

Hi ,
I tried examples todos, tour both on master branch (commit 416e002) today and also made the same examples using iced version 0.10 and I am using Nvidia prop drivers 545.29-6.1 on Arch, Wayland, using Hyprland .

the GUI opens but I can not input any text or click buttons and not even close the GUI unless I do Ctrl-C from the terminal. GUI looks like it is frozen

I saved the output when I run cargo run --package todos into text file in case if it helps to debug
todo_run_output.txt

@ids1024
Copy link
Contributor

ids1024 commented Jan 22, 2024

The issue with freezing on Nvidia + Wayland should be fixed by gfx-rs/wgpu#4967. Though that doesn't seem to have been included in the wgpu latest release.

@salimp2009
Copy link

The issue with freezing on Nvidia + Wayland should be fixed by gfx-rs/wgpu#4967. Though that doesn't seem to have been included in the wgpu latest release.

When do you think we should expect it to be included in your create ?

@ids1024
Copy link
Contributor

ids1024 commented Jan 22, 2024

That's a change to wgpu rather than iced, so you'd have to ask the wgpu maintainers. Unless Iced switches to a patched version of wgpu.

You should be able to override the version of wgpu used by any of your program's dependencies by adding something like this to Cargo.toml:

[patch.crates-io]
wgpu = { git = "https://github.com/gfx-rs/wgpu", rev = "ac8756c" }

@salimp2009
Copy link

That's a change to wgpu rather than iced, so you'd have to ask the wgpu maintainers. Unless Iced switches to a patched version of wgpu.

You should be able to override the version of wgpu used by any of your program's dependencies by adding something like this to Cargo.toml:

[patch.crates-io]
wgpu = { git = "https://github.com/gfx-rs/wgpu", rev = "ac8756c" }

I started learning iced. so dont have directly dependency to wgpu but maybe make a local branch of iced and change the wgpu dependency like that until it is resolved.
Right now I did a workaround by setting WGPU_BACKEND=GL in my environment settings wayland/hyprland and then it works but uses OpenGL backend

@Friz64
Copy link
Contributor

Friz64 commented Jan 22, 2024

This is [patch.crates-io], which is not necessarily about direct dependencies of your crate. It essentially replaces every wgpu dependency that exists in the dependency graph with the specified git version. Try adding those two lines to the end of your Cargo.toml.

@salimp2009
Copy link

wgpu = { git = "https://github.com/gfx-rs/wgpu", rev = "ac8756c" }

Shall I put that first and then iced in my example crate, will that work ?
i did put iced in the example crate & the patch you gave but it did not work
When you said put it on Cargo.toml , is that the example crate Cargo.toml or is that a global Cargo.toml ?

@Friz64
Copy link
Contributor

Friz64 commented Jan 22, 2024

diff --git a/Cargo.toml b/Cargo.toml
index c9dee6b7..5a3ad548 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -162,3 +162,6 @@ wgpu = "0.19"
 winapi = "0.3"
 window_clipboard = "0.4"
 winit = { git = "https://github.com/iced-rs/winit.git", rev = "b91e39ece2c0d378c3b80da7f3ab50e17bb798a5" }
+
+[patch.crates-io]
+wgpu = { git = "https://github.com/gfx-rs/wgpu", rev = "ac8756c" }

Just tried it myself on iced master. I got a warning from Cargo that told me to run cargo update, after which it worked.

@salimp2009
Copy link

I have this

[package]
name = "counter_iced"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
iced = "*"

[patch.crates-io]
wgpu = { git = "https://github.com/gfx-rs/wgpu", rev = "ac8756c" }

cargo gives me this warning, and when I run cargo update , it gives it again

warning: Patch `wgpu v0.19.0 (https://github.com/gfx-rs/wgpu?rev=ac8756c#ac8756c2)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.

@Friz64
Copy link
Contributor

Friz64 commented Jan 22, 2024

Oh. Yes. You're depending on the crates.io version of iced, which is too old for that new wgpu patch. You would need to depend on the git version of iced, by setting

[dependencies]
iced = { git = "https://github.com/iced-rs/iced.git", rev = "a1114ca" }

@salimp2009
Copy link

salimp2009 commented Jan 22, 2024

[dependencies]
iced = { git = "https://github.com/iced-rs/iced.git", rev = "a1114ca" }

UPDATE : thank you it worked awesome :)
and I just learned how to apply a patch on the fly. just another reason to love Rust & community
i will try . thanks

@salimp2009
Copy link

salimp2009 commented Jan 23, 2024

after applying wgpu patch as above, also the performace looks good too.
running the counter example with debug on Wayland,
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants