ActivityWatch / activitywatch

The best free and open-source automated time tracker. Cross-platform, extensible, privacy-focused.
https://activitywatch.net/
Mozilla Public License 2.0
11.82k stars 537 forks source link

big periods of 'loginwindow' recorded when macbook is closed #810

Open rtpHarry opened 1 year ago

rtpHarry commented 1 year ago

Describe the bug

Since the latest version it is picking up loginwindow when my laptop is closed:

image

Looks like AFK is still registering ok:

image

Don't know if this is classed as a bug, bit it feels like one, and is different behaviour to v0.11

BelKed commented 1 year ago

I can reproduce this "bug" on the same OS and version.

The cause of this "bug" is the usage of another windows watching strategy implemented in 0.12.1 (https://github.com/ActivityWatch/aw-watcher-window/commit/fc423c1d95e65b269e23d9f424fc7bfc38777e52, https://github.com/ActivityWatch/aw-watcher-window/commit/6d68ae35353bd43e8f0c7235a2a613dcfb272c17).

cachedout commented 1 year ago

I can also confirm this behavior using ActivityWatch v0.12.1 with MacOS Ventura 13.2 and it certainly feels like a bug to me. IMHO it should be quite clear that if the laptop is shut, no windows should be monitored.

@ErikBjare Since it looks like you were in the code mentioned by @BelKed , is there any chance that a fix might be on your radar? :)

EDIT: I think this may be a duplicate of https://github.com/ActivityWatch/aw-watcher-window/issues/85

ErikBjare commented 1 year ago

Yeah this is kind of a bug, althought doesn't really impact normal use (unless you look at data that isn't AFK filtered).

It's ultimately a side-effect of switching to event-based window watching (assuming windows stay active until we get notified otherwise) over polling (checking what the active window is every x sec).

Me and @iloveitaly have discussed adding a "hybrid polling" method to the new window watching strategy to fix another issue (where window-switch events are not triggered for some reason), which could solve this issue at the same time. (can't find original discussion, but was mentioned by @modderme123 here: https://github.com/ActivityWatch/aw-watcher-window/pull/69#issuecomment-1264419382)

milomg commented 1 year ago

I used https://github.com/ActivityWatch/aw-watcher-window/pull/68#discussion_r914355460 in the past, but I think we deleted that?

cachedout commented 1 year ago

Yeah this is kind of a bug, althought doesn't really impact normal use (unless you look at data that isn't AFK filtered).

FIltering by AFK seems to be a fairly good workaround on the Activity page but this bug is still quite noticeable on the Timeline page. (I think this was implicit in your point, but I just wanted to call it out specifically.) Thanks for the reply and for the project. It's quite good!