aardappel / procrastitracker

a Windows time tracking application
http://strlen.com/procrastitracker/
510 stars 54 forks source link

PT cannot recreate taskbar icon #46

Open expwnent opened 6 years ago

expwnent commented 6 years ago

Whenever I'm not connected to the internet, if I have a fullscreen game open for a few minutes, the game will minimize and I'll get a popup from procrastitracker saying that it cannot recreate the taskbar icon. Procrastitracker then crashes. Exiting and restarting PT does not fix it: I get the same problem a few minutes later. When I am connected to the internet everything is fine: it does not crash, even while full screen games run.

aardappel commented 6 years ago

Hmm that is weird, PT certainly does not require the internet in any way.

Recreating the taskbar Icon is something it is only supposed to do when explorer crashes / is restarted, as that causes the taskbar to be re-created. Can it be that your game going full-screen causes the taskbar to not just be hidden, but to be re-created? Do you have any interesting window management apps running? What game is this?

I play a LOT of games, and have never seen this issue. Does it happen only with this one game?

The code for this is here: https://github.com/aardappel/procrastitracker/blob/master/src/procrastitracker.cpp#L363 It has to wait before re-creating (3 seconds), and I wonder if that is too fast on your system). We could try increasing that number and see if that fixes it for you.

expwnent commented 6 years ago

It must be something weirdly correlated with when my PC is connected to the internet and when it's not then. I do have a program doing somewhat mysterious things with full screen programs (game companion: https://www.nexusmods.com/skyrim/mods/39594 ) but I don't know why it would act differently when I'm online and when I'm not, and I don't know specifically what it's doing that would interfere with PT. It's the most likely candidate for what's causing the problem.

I have had the same issue with both Skyrim (on Steam) and Divinity Original Sin 2 (from GoG), so it isn't specific to a particular game or to Steam.

I'll try running D:OS2 offline without Game Companion running and let you know what happens.

Alt-Tabbing does take a few seconds to stabilize, so that might be related. The crash does happen both when I start the full screen game and when I alt-tab back to it after manually restarting PT. I don't know if windows handles those differently though. I could try making an AutoHotKey script to restart PT without alt-tabbing away from the full screen game to see if that helps. If that fixes it then it's the transition between desktop and full screen game that's the problem, and if it doesn't then it's something else.

aardappel commented 6 years ago

Ok, let's first see what running without "game companion" does, because from its description it wouldn't surprise me if it interfered with the taskbar.

expwnent commented 6 years ago

I tried it again offline without GC. Bizarrely, I got the same problem, except now instead of 5-10 seconds passing before PT crashes, it's a couple minutes. I don't think I'm running anything else unusual on my system, so I have no idea what the problem might be.

aardappel commented 6 years ago

Hmm, maybe I can make the timeout I linked to in the code above configurable, such that you can see if increasing it stops the error from appearing? Not the greatest solution, but maybe we'll learn something.

dzfranklin commented 6 years ago

I got the same error when running VLC fullscreen, and my database was deleted. I just installed it, so I only lost a few hours, but it's worrying to me. Is there a way to regularly backup the database?

aardappel commented 6 years ago

@danielzfranklin I seriously doubt it deleted your database. It saves your db every 10 minutes, and makes a backup of the last save when it does so. Then each day it makes an additional dated backup.

From the website:

the installer provides a shortcut to where all database files are stored. This allows you to restore old databases in case of an emergency (just rename the one with the date you want to "db.PT"), backup the database on other media, move the database to a new machine, delete old backups to save space, etc.

aardappel commented 6 years ago

And I also use VLC fullscreen, and never had this issue?

dzfranklin commented 6 years ago

Yes. It didn't show the contents of my database, and instead only showed the events recorded after I restarted the application, but when I restarted the computer the contents from before and after the crash were both there.

On Tue, Nov 20, 2018, 7:58 AM Wouter van Oortmerssen < notifications@github.com wrote:

@danielzfranklin https://github.com/danielzfranklin I seriously doubt it deleted your database. It saves your db every 10 minutes, and makes a backup of the last save when it does so. Then each day it makes an additional dated backup.

From the website:

the installer provides a shortcut to where all database files are stored. This allows you to restore old databases in case of an emergency (just rename the one with the date you want to "db.PT"), backup the database on other media, move the database to a new machine, delete old backups to save space, etc.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aardappel/procrastitracker/issues/46#issuecomment-440324970, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ4b9sqwm2sHx8unVrKHbwEPEesNt24Lks5uxCaWgaJpZM4XtibV .

peterschussheim commented 4 years ago

Hi Wouter,

I've gotten the same "PT cannot recreate taskbar icon" popup. I can reproduce on my machine consistently via the following steps:

I haven't had any issues, I just click OK and proceed. No crashes, no data loss. Just thought I'd share this and would be happy to provide logs if it will help. Thanks for PT and TreeSheets!

aardappel commented 4 years ago

Hmm, let me see if I can reproduce that.. note that PT does not use the network in any way, so that shouldn't matter..

azeemba commented 4 years ago

I was consistently getting the "PT cannot recreate taskbar icon" popup when launching a game. I play the game fullscreen at a smaller resolution than the normal desktop resolution. This results in things like the taskbar moving a bit.

Since I was able to reproduce this so easily, I tried to figure out what the issue was. Turns out WM_TASKBARCREATED is sent even if the taskbar isn't really recreated. My desktop resolution changed and taskbar moved but none of the notification icons are destroyed. So when the CreateTaskBarIcon function tries to recreate the icon, it fails since the previous icon is still there and functioning.

In fact, the CreateTaskBarIcon function tries to create the notification so many times, it actually was resulting in the application hanging for me.

Unfortunately this means I don't really have a good solution for us. I am just going to disable the handling for WM_TASKBARCREATED for myself, but I imagine that's not a valid trade-off for everyone.

aardappel commented 4 years ago

@azeemba thanks for the tip, it could well be that adding the icon is failing, so I modified the code to first try to modify the existing icon, such that if that succeeds, it doesn't try and add it, and doesn't fail: https://github.com/aardappel/procrastitracker/commit/ba2682bfd87c582b89cf65116ad7bce61a0d867e

I haven't tested this code however, since I don't get this particular situation for some reason.

Also reduced the amount of times it will retry, such that it is less likely to hang.

azeemba commented 4 years ago

I was able to test the changes and they fix the issue for me! No popup and no hanging.

Thanks a lot for such a quick response.

aardappel commented 4 years ago

Thanks @azeemba :)

I've also updated the installer, so others on this issue can see if its an improvement for them too.

SchittBull commented 3 years ago

Hey, I haven't tried the new version yet but for me the pop up (together with a 10second freeze or so) happens when ever I change my monitor configuration (change resolution or add/disconnect a monitor)

aardappel commented 3 years ago

I've disabled the pop-up entirely, since it wasn't possible to reliably detect when its needed. Also increased the retry time to compensate. Downside: there may be situations where you'll not get your taskbar button back. No idea how to fix that.