awatcher: Stops working randomly

Running Archlinux + Hyprland.

I’m using bundled awatcher and starting it like:

exec-once = telegram-desktop & awatcher

It starts well and runs at first, then randomly it crashes. I don’t have a log or something unfortunately, if you can guide me how to get it I can provide that.

Example: image

as you can see I was not AFK and was on meet but all of a sudden awatcher stops recording. Weird thing is the server works all the time, I can access localhost:5600 all the time.

This is an example of random day, it happens almost every day.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 1
  • Comments: 16 (12 by maintainers)

Most upvoted comments

I also noticed this issue and there seems to be two issues at play:

  1. Watcher fails to return from watcher.run_iteration (fixed by timeout)
  2. For wayland apps, after suspending for a relatively long period of time, awatcher starts to raise [2024-05-19 22:04:58.559502 ERROR watchers::watchers] Error on active window iteration: GetPropertyReply[_NET_WM_NAME] failed (should be fixed by commenting out X11 window watcher but have yet to test it)

Issue doesn’t occur for me on v0.2.7 of awatcher (installed as module) with hyprland v0.40.0-1 image (my computer was suspended at the blank point in the middle)

If this is true, maybe we should further bisect what in run_iteration fails to return?

If you use Gnome and given the symptoms, it means that DBus call to org.gnome.shell.extensions.FocusedWindow hangs at some moment. There is only that call (and reporting to AW server).

timeout(watcher_type.sleep_time(&client.config), watcher.run_iteration(&client)).await

@luisgerhorst Your change looks good and universal to hopefully exclude similar problems in this and other watchers. It’s simple and free to try anyway. I can commit the change in a few days for 0.2.7, or preferably merge your PR if you push it (with other watchers enabled). Thanks regardless ❤️

@luisgerhorst why could it be? E.g. why have you added timeouts in a couple places, and removed the reconnect attempts for Gnome watchers? I see that your changes only affect the watcher loading/initializing but I’ve got an impression that the failures happen long after loading, during normal functioning.

I’ve been using @luisgerhorst’s fork since May 3, and the problem has not happened since then.

Just wanted to let you know that I’ve now built awatcher from source (all worked like a charm) and disabled some of the other watchers. I’ve now been running that debug build for 2 weeks and have not been able to reproduce the issue since. I will continue to debug and try to pinpoint it.

Here’s the changes I made: https://github.com/luisgerhorst/awatcher/commit/26d2f2e67bcd03b4c291dee150fb4cadeeae76a7 - However, it could also be just a coincidence at this point…

Here you go:

Hardware Information:

  • Hardware Model: Lenovo ThinkPad X1 Carbon Gen 9
  • Processor: 11th Gen Intel® Core™ i7-1185G7 × 8
  • Graphics: Intel® Xe Graphics (TGL GT2)

Software Information:

  • Firmware Version: N32ET90W (1.66 )
  • OS Name: Fedora Linux 39 (Workstation Edition)
  • GNOME Version: 45.4
  • Windowing System: Wayland
  • Kernel Version: Linux 6.7.9-200.fc39.x86_64

In extensions, I see a 6 behind the name of https://github.com/flexagoon/focused-window-dbus, not sure if that is the version.

> aw-awatcher --version
Activity Watcher 0.2.4
> cat ~/.config/systemd/user/aw-awatcher.service 
[Unit]
Requires=aw-server.service
After=aw-server.service

[Service]
Type=simple
# Verbosity level: -v for warnings, -vv for info, -vvv for debug, -vvvv for trace
ExecStart=/bin/bash -c 'aw-awatcher -vvvv'
Restart=always
RestartSec=60
RuntimeMaxSec=1h
Nice=18
IOSchedulingPriority=6
# Was not able to test this on a system where it has an effect:
# CPUQuota=10%

[Install]
WantedBy=default.target
> cat ~/.config/systemd/user/aw-server.service  
[Unit]
After=network.target

[Service]
Type=simple
ExecStart=/bin/bash -c 'aw-server'
Restart=on-failure
RestartSec=60
Nice=18
IOSchedulingPriority=6
# Was not able to test this on a system where it has an effect:
# CPUQuota=10%

[Install]
WantedBy=default.target

I also get vastly wrong usage times in the overview of the web interface.

A also see this happening, with both standalone and bundled versions. I noticed the following:

  • it usually happens when the machine is suspended/resumed
  • at the same time, I stop getting messages like these:

[2024-02-12 08:28:02.469725 DEBUG watchers::watchers::gnome_window] Changed window app_id=…

  • and start geting messages like these:

[2024-02-12 09:15:17.336292 WARN aw_transform::flood] Gap was of negative duration and could NOT be safely merged (-PT183.376476271Ss). This warning will only show once per batch. [2024-02-12 09:15:17.336310 WARN aw_transform::flood] Gap was of negative duration (-PT388.971761192Ss), but could be safely merged. This error will only show once per batch.