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

[Bug]: Constant CPU usage while idle #145

Closed
nekohayo opened this issue Mar 31, 2023 · 5 comments · Fixed by #146 or #222
Closed

[Bug]: Constant CPU usage while idle #145

nekohayo opened this issue Mar 31, 2023 · 5 comments · Fixed by #146 or #222
Labels
bug Something isn't working

Comments

@nekohayo
Copy link

Describe the bug

My CPU, it eats it! 🔥 And my laptop fan spins as long as Tuba is running.

Steps To Reproduce

  1. Launch Tuba, with one or more accounts correctly set up
  2. Let it sit idle on the "Home" tab, or even just on your own profile (where nothing happens; by clicking your profile name in the sidebar)
  3. Watch the CPU usage using top, htop, or sysprof

Logs and/or Screenshots

top:

Screenshot from 2023-03-31 14-55-16

sysprof (I don't really know what to be looking for here):

Screenshot from 2023-03-31 15-02-57

Instance Backend

Mastodon

Operating System

Fedora 37

Package

Flatpak

Troubleshooting information

os: GNOME 44 (Flatpak runtime)
prefix: /app
flatpak: true
version: 0.1.0 (production)
gtk: 4.10.1 (4.10.1)
libadwaita: 1.3.1 (1.3.1)
libsoup: 2.74.3 (2.74.3)

Additional Context

I'm running on the Xorg/X11 version of GNOME.

@nekohayo nekohayo added the bug Something isn't working label Mar 31, 2023
@GeopJr
Copy link
Owner

GeopJr commented Apr 1, 2023

I'm having a bit of trouble reproducing on my machine. Since you mention idling, my only speculation is libsoup. Could you give this artifact a try, it uses libsoup3 instead of 2? https://github.com/GeopJr/Tuba/suites/11930574088/artifacts/625061733

You can install it with flatpak install ./path/to/dev.geopjr.Tuba.Devel.flatpak (--user)

Other than that, I'd say everything looks like is using a bit too much cpu, for example gnome-shell rarely goes over 1% on my machine.

Do other (internet connected) GTK4 apps cause similar usage? Like Dino or Fractal?

This definitely needs more investigation

edit:
just to be a bit more clear: Tuba has active websocket connections - even when in the background that might be the culprit for the CPU usage

@nekohayo
Copy link
Author

nekohayo commented Apr 1, 2023

I'm having a bit of trouble reproducing on my machine.

Maybe your CPU/GPU is a bit too recent to notice? It's easier to spot such performance problems when running, say, a ThinkPad X220 with a Sandybridge (2nd gen) Intel Core i5 processor :) what if you throttle down your CPU to simulate this? Or maybe in a VM with slow graphics?

Do other (internet connected) GTK4 apps cause similar usage? Like Dino or Fractal?

Haven't tried those, but I doubt they'd be affected "just by virtue of using GTK", typically this kind of stuff is an app doing needless work; it could be something silly like a hidden gtk spinner or something... That was the cause for this issue in GNOME Calendar, for example.

The GNOME Shell CPU usage shown there is not "on its own", it's triggered by the app (it drops to zero as soon as you stop Tuba), usually by something spamming the graphics stack I would suspect. That was also the case with the GNOME Calendar spinner bug.

@GeopJr GeopJr linked a pull request Apr 2, 2023 that will close this issue
@GeopJr
Copy link
Owner

GeopJr commented Apr 2, 2023

Thanks for the info!

I mostly wanted you to try those apps because they also do similar web requests but I see that the issue does not lie there

...

It was actually the spinning issue here too 😳

Thanks for linking that issue, I'd never have guessed!

You can download the artifact to give it a try from here when they are done: https://github.com/GeopJr/Tuba/actions/runs/4587824331

image

@nekohayo
Copy link
Author

nekohayo commented Apr 5, 2023

Thanks for the fix! Can confirm that the new version available through Flathub now does not consume my CPU. Incidentally, I think this helps with fluidity in the rest of the app as well, such as while scrolling.

@nekohayo
Copy link
Author

Hmmm, are you sure you fixed this for all spinners throughout the code? I experienced some similarly high CPU usage today running the latest flatpak flathub version, I'm not sure under which conditions exactly, but I think it was when I clicked the "Notifications" tab and it was showing a spinner indefinitely (at that time it seems the main mastodon instance/server was too overloaded to respond to that) and the CPU usage persisted even when I switched back to "home" or other tabs/views, until I restarted the app. It might be that the spinner there only halts when it stops trying to load (which, in this case, was never) and not also based on its visibility?

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
2 participants