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

swaybar repeatedly polling various files #3789

Closed
mxmilkiib opened this issue Feb 27, 2019 · 5 comments · Fixed by #4229
Closed

swaybar repeatedly polling various files #3789

mxmilkiib opened this issue Feb 27, 2019 · 5 comments · Fixed by #4229
Labels
bug Not working as intended

Comments

@mxmilkiib
Copy link

sway version 1.0-rc1-123-gd016848b

Specific tray apps seem to make swaybar repeatedly poll for image/asset files.

kdeconnect-indicator doesn't do it, but kmix, radiotray-ng (gtk) and soulseekqt do. the icon for kmix is a red face, but the radiotray-ng and soulseekqt icons appear as they should.

swaybar CPU usage without any tray apps is about 0.5%. For each troublesome app open, it goes up roughly by 3.5/5%.

sway.log

swaystrace.log

@bonktree
Copy link

I can confirm that telegram-desktop 1.5.11 and mumble 1.2.19 also cause this on sway 1.0-rc3.
By the way, the colours of telegram-desktop's tray icon are messed up as well (#3635).

approximately 15 seconds of stracing swaybar with tdesktop's icon in the tray

@ianyfan
Copy link
Contributor

ianyfan commented Feb 28, 2019

This issue is now being tracked in #3799.

The kmix issue is, I think, a case of missing icons. It's looking for an icon called 'audio-volume-high' or something, does that exists on your filesystem?

@mxmilkiib
Copy link
Author

Hmm. Whilst tray support isn't final, it appears the individual apps could be more conservative. Not sure how much swaybar can do when apps do this, are the apps expecting some specific tray feature, or are they just generally misbehaving?

ebruck/radiotray-ng#103

@emersion
Copy link
Member

emersion commented Mar 1, 2019

Maybe an icon name cache could be implemented. Or maybe it's just an app bug.

@ianyfan
Copy link
Contributor

ianyfan commented Mar 1, 2019

Maybe an icon name cache could be implemented.

This is the solution. Here is a full outline of the problem:
Icon themes define, for each size of icon, its range of acceptable rendering sizes, e.g. it may say that icons of size 22x22 can be resized to between 20 & 24 to be rendered. Hence, when swaybar searches for an icon to render, it tries to find an icon for which the current rendering height falls within the icon's acceptable range for rendering, but if that is not possible, it then finds the icons whose acceptable range is closest to the rendering size.
In each case, it also stores the acceptable range, with the idea that if the height of swaybar changes so that it falls out of that range, it can look for a new icon again. However, this has the side-effect that if the icon was not in the acceptable range to begin with, it will look for a new icon if the height does not change, which is usually the status quo, causing swaybar to poll every single possible icon file twice on every render.
As outlined in the specification the main solution would be to only traverse the file tree once, reading it all into memory, but this would require more implementation work, when initially I was just pushing to get the feature out there in a way that works. However, there could also be more state defined to monitor if the height changes, since if it does not, the icon should not change either.

Sorry for this problem, but I hope you understand why it's happening. When I get time, I hope to revisit this problem, since it's not too conceptually hard, just fiddly to work out the details, but in the meantime, contributions are welcome :)

@emersion emersion added the bug Not working as intended label Mar 8, 2019
kupospelov added a commit to kupospelov/sway that referenced this issue Jun 8, 2019
In case a tray icon cannot be found or does not have a desirable size,
swaybar retries the search again and again, which increases load on disk
and CPU. This commit solves it by storing target_size for each icon, so
that swaybar does not search for an icon of some size if it already tried to.

Fixes swaywm#3789.
kupospelov added a commit to kupospelov/sway that referenced this issue Oct 16, 2019
In case a tray icon cannot be found or does not have a desirable size,
swaybar retries the search again and again, which increases load on disk
and CPU. This commit solves it by storing target_size for each icon, so
that swaybar does not search for an icon of some size if it already tried to.

Fixes swaywm#3789.
emersion pushed a commit that referenced this issue Oct 21, 2019
In case a tray icon cannot be found or does not have a desirable size,
swaybar retries the search again and again, which increases load on disk
and CPU. This commit solves it by storing target_size for each icon, so
that swaybar does not search for an icon of some size if it already tried to.

Fixes #3789.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended
Development

Successfully merging a pull request may close this issue.

4 participants