ActivityWatch / aw-watcher-window

Cross-platform window watcher (for use with ActivityWatch)
Mozilla Public License 2.0
88 stars 53 forks source link

Code makes unclear branches #22

Open nikanar opened 7 years ago

nikanar commented 7 years ago

I got a large bunch of 2017-07-26 03:28:42,691 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) (what does it mean ?), seemingly for all the heartbeats in a 20s period ?

full log ``` 2017-07-26 03:28:42,691 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:42,693 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:42,695 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:43,702 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:43,704 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:43,706 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:44,711 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:44,713 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:44,715 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:45,722 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:45,724 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:45,726 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:46,730 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:46,731 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:46,731 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:48,736 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:48,738 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:48,740 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:49,745 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:49,748 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:49,750 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:50,757 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:50,759 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:50,761 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:51,766 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:51,768 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:51,770 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:52,774 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:52,776 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:52,777 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:53,781 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:53,782 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:53,782 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:54,786 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:54,788 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:54,789 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:55,796 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:55,798 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:55,801 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:56,807 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:56,810 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:56,813 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:57,819 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:57,819 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:57,820 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:58,821 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:58,822 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:58,823 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:59,826 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:59,827 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:28:59,827 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:00,830 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:00,831 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:00,832 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:01,833 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:01,834 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:01,834 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:02,837 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:02,838 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:02,839 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:03,843 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:03,845 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:03,846 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:04,849 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:04,850 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:04,850 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:05,854 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:05,855 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:05,856 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:06,861 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:06,863 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) 2017-07-26 03:29:06,866 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) ```

It was 5 minutes ago and AW didn't crash, but iirc other crashes (in https://github.com/ActivityWatch/aw-watcher-window/issues/19) were preceded by this happening.

johan-bjareholt commented 7 years ago

Thanks for reporting this, have seen that code before but i wasn't the one who wrote it so I had just ignored it and assumed that it worked.

I have previously seen "unknown" appnames in the webui and wondered where they came from, and I now see that at least some seem to be created at that code path, but in my case i get "unknown" appnames but still without that log message which is very odd.

Can you check exactly what event(s) is in the aw-watcher-window bucket during that timeperiod?

nikanar commented 7 years ago

Here you are @johan-bjareholt :

In [17]: for e in afk_events[3835:3824:-1]:
    ...:     print(e['timestamp'], "==", str(e['duration']), "==", e['data'])
    ...:     
2017-07-26 03:28:33.158000+00:00 == 0:00:00 == {'app': 'Emacs', 'title': 'index.html'}
2017-07-26 03:28:34.161000+00:00 == 0:00:00 == {'app': 'unknown', 'title': 'unknown'}
2017-07-26 03:28:35.165000+00:00 == 0:00:00 == {'app': 'Google-chrome', 'title': 'Untitled spreadsheet - Google Sheets - Google Chrome'}
2017-07-26 03:28:36.170000+00:00 == 0:00:03.012000 == {'app': 'Terminator', 'title': 'cd 01-Conferences/2014-07\\ TALN/'}
2017-07-26 03:28:40.188000+00:00 == 0:00:00 == {'app': 'Google-chrome', 'title': 'Défis en OpenIE, le cas « Gonzales » - Google Chrome'}
2017-07-26 03:28:41.195000+00:00 == 0:00:00 == {'app': 'Google-chrome', 'title': 'valeriobasile/learningbyreading: Learning by Reading pipeline of NLP and Entity Linking tools - Google Chrome'}
[ warnings start at 03:28:42,691 ↓]
2017-07-26 03:28:42.200000+00:00 == 0:00:12.051000 == {'app': 'Terminator', 'title': 'cd 01-Conferences/2014-07\\ TALN/'}
2017-07-26 03:28:55.253000+00:00 == 0:00:03.007000 == {'app': 'Terminator', 'title': 'll'}
2017-07-26 03:28:59.262000+00:00 == 0:00:01.004000 == {'app': 'Terminator', 'title': 'll Tal'}
2017-07-26 03:29:01.269000+00:00 == 0:00:08.028000 == {'app': 'Terminator', 'title': 'll Talk/'}
[ Last warning during this ↑ ]
2017-07-26 03:29:10.299000+00:00 == 0:00:00 == {'app': 'Terminator', 'title': 'evince Talk/Presentation-TALN-2014.pdf '}

"Can't reproduce", in that I can open windows with same data without getting warnings (and at 03:28:36 I was already in the same window that at 03:28:42, but there were no warnings yet) . The warnings cover a range of open windows, and do not stop at an event boundary.

I also have an "unknown" appname right at the top. Could be due to some kind of interval in-between switching windows (like switching to a virtual desktop to another, or between physical screens), maybe ?

ErikBjare commented 7 years ago

Could be due to some kind of interval in-between switching windows (like switching to a virtual desktop to another, or between physical screens), maybe ?

This is very likely the cause. IIRC I got this in xmonad when no window was active (such as having an empty workspace open). There might be other things that cause this however, but I'm not sure.

That's why I wrote the logging message originally. Creating unknown events seemed like the reasonable thing to do.

If you want to check what happens to X11: Try to use xprop to get the active window. Code that does this, but is no longer used since it caused a dependency on xorg-tools or some other package, can be found here. If on a empty workspace it should return a very nothing-like output.

A reasonable action to take: Make the message more informative, such as: "Code made an unclear branch. This usually happens when no window is active on some platforms, if this is not the case, please file an issue. (related to aw-watcher-window issue #22)"

johan-bjareholt commented 7 years ago

That's why I wrote the logging message originally. Creating unknown events seemed like the reasonable thing to do.

@ErikBjare Maybe rename it to "None" rather than "Unknown" though, since we know that it's due to no window being focused rather than an "Unknown" window being focused?

ErikBjare commented 7 years ago

@johan-bjareholt Good point but I'm not sure if it is always causes that nor if it is the only cause. I need verification.

I will check how common it is on my laptop vs desktop. (Laptop runs Xfce4, desktop runs Xfce4 + xmonad)

nikanar commented 7 years ago

I can generate "unknown" at will by minimizing all windows and staring at my desktop background. That seems to answer @johan-bjareholt first post question "where do they come from".

But just like him, I don't get WARNING Code made an unclear branch when that happens, so these warnings must come from something else (and as you can see, there was only one 0-duration "unknown" happening 8s before the warnings, seems unrelated).