qtile-extras
qtile-extras copied to clipboard
Visualizer utilization issue
When I leave the visualizer enabled in my config, after a few hours my computer is highly unresponsive and htop shows qtile pegging 100% utilization. It goes away when I reload, but always comes back after a few hours. I think this might be related to some of my other performance-related tickets I have filed here or on the main repo. Disabling visualizer makes the problem go away.
Maybe qtile/qtile#3877 is related.
The segfault doesn't happen when this widget is disabled.
There's definitely something wrong with this widget. Feels like a memory leak but not entirely obvious where it's coming from.
The segfault is linked to this and should be fixed in #158.
Would be great if you could test.
2022-11-08 14:07:09,791 ERROR libqtile manager.py:spawn():L1197 couldn't find `/usr/lib/python3.10/site-packages/qtile_extras/resources/visualiser/cava_draw.py`
2022-11-08 14:07:10,794 ERROR libqtile base.py:_wrapper():L355 got exception from widget timer
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/libqtile/widget/base.py", line 353, in _wrapper
method(*method_args)
File "/usr/lib/python3.10/site-packages/qtile_extras/widget/visualiser.py", line 172, in _open_shm
self._lockfile = open(LOCK, "rb+")
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/lock.mmap'
Sigh...
That file should have been created by the separate cava_draw.py process. Can you check if that's running?
Sorry, missed a line in the error message. Might be relevant. The file is definitely there though...
> ll
total 20
drwxr-xr-x 3 root root 4096 Nov 8 14:00 .
drwxr-xr-x 13 root root 4096 Nov 8 14:00 ..
-rw-r--r-- 1 root root 4951 Nov 8 14:00 cava_draw.py
-rw-r--r-- 1 root root 0 Nov 8 14:00 __init__.py
drwxr-xr-x 2 root root 4096 Nov 8 14:00 __pycache__
Can you try running python /usr/lib/python3.10/site-packages/qtile_extras/resources/visualiser/cava_draw.py from a terminal.
> python cava_draw.py --width 100 --height 32 --bars 12 --spacing 2 --pipe /tmp/cava.pipe --background "#ffffff"
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/qtile_extras/resources/visualiser/cava_draw.py", line 139, in <module>
draw_cava(
File "/usr/lib/python3.10/site-packages/qtile_extras/resources/visualiser/cava_draw.py", line 49, in draw_cava
with mmap.mmap(
PermissionError: [Errno 13] Permission denied
Well that's even stranger as it can open the file (as opposed to file not found error message).
What I don't understand is why it worked when I tested it and now I'm getting the same error today.
Pushed a change. Working again for me now.
Something is still off for me. After rebooting, I got this:
2022-11-08 15:50:59,572 ERROR libqtile manager.py:spawn():L1197 couldn't find `/usr/lib/python3.10/site-packages/qtile_extras/resources/visualiser/cava_draw.py`
2022-11-08 15:51:00,573 ERROR libqtile base.py:_wrapper():L355 got exception from widget timer
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/libqtile/widget/base.py", line 353, in _wrapper
method(*method_args)
File "/usr/lib/python3.10/site-packages/qtile_extras/widget/visualiser.py", line 172, in _open_shm
self._lockfile = open(LOCK, "rb+")
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/lock.mmap'
I tried launching it manually to see and permissions are working there - no errors at least. I restarted qtile with qtile cmd-obj -o cmd -f restart then tried again and got this in the log:
2022-11-08 15:51:40,205 ERROR libqtile manager.py:spawn():L1197 couldn't find `/usr/lib/python3.10/site-packages/qtile_extras/resources/visualiser/cava_draw.py`
2022-11-08 15:51:41,206 ERROR libqtile base.py:_wrapper():L355 got exception from widget timer
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/libqtile/widget/base.py", line 353, in _wrapper
method(*method_args)
File "/usr/lib/python3.10/site-packages/qtile_extras/widget/visualiser.py", line 176, in _open_shm
self._shm = mmap.mmap(
ValueError: mmap length is greater than file size
cava_draw.py should be executable. Can you try making it executable and see if that makes a difference?
If it does, I'll update the widget so it just calls the script via python <script> instead. (EDIT: I've done this - please test when you get a chance)
I pulled your update and the visualizer is visible again! I will let it run for a while to confirm I don't see any memory leak issues.
However, the bars it shows don't seem to match the bars if I run Cava directly. The beat seems to match, but the shape looks off some of the time.
It doesn't do the symmetry that cava does by default. Is that the difference you're seeing?
Yeah that is probably it. The left side seems more accurate than the right side. Cava directly supports a configurable number of bars - is it possible to pass that number through in a config and mirror cava more directly?
Setting the number of bars in the widget changes the cava config for the widget.
I can add the option for the mirroring if that's desirable.
Yeah that would be nice, I was expecting it to be a full, tiny visualizer I guess.
Ok - I've added the ability to have mirrored look. Pull the latest update and set channels='stereo' in the config.
Not sure what else you're after so let me know if there's anything else missing.
By default, the widget is meant to be small but you can make it as big as you want with as many bars as you want.
That is looking really good. I am still seeing a higher CPU utilization with it enabled vs not, but I haven't seen any slowdown yet so maybe it is fine.
CPU is going to be higher with it running as the widget is polling the data every 1/framerate seconds and you've got a script running to create the bar image at the same frequency and you've got cava running.
However, it sounds like it's good enough to merge for now!