jlaumon / AssetCooker

Asset Cooker is a build system aimed at game assets, for custom engines. It leverages Windows' USN journals to robustly track which files change, and only cook what needs to be cooked.
Mozilla Public License 2.0
219 stars 6 forks source link

Notification icon fails to create in some scenarios #5

Open Eiyeron opened 2 days ago

Eiyeron commented 2 days ago

Hello, during my tests I noticed that the tray icon (or the notification icon) tends to fail its initialization and triggers the assert in gNotifInit. When that happens, the program can still be "minimized to the icon" (or hidden) that doesn't exist, making it hard to pop it back up.

From my own testing, I'm drawing a conjecture that it looks like it fails to create the icon when there's a remaining one from a previous instance that wasn't properly cleaned up, as if something killed the process to re-run it, like your favorite IDE might do to re-run debugging sessions. Orphaned, those icons are usually deleted once you hover your mouse cursor over them (or having any of the desktop shell crash), fixing the problem in the same time.

I think I might see two ways to "fix" or get around the problem:

  1. Experiment and find a way to reuse the orphaned icon for the new instance instead of directly assert on failure to create the icon
  2. Because killing a process like a debugger or the Task Manager does seems to not trigger standard exit hooks like atexit, there might be a way to hook to the lower level OS' termination functions to detect when the program is going to be kill -9 and destroy the icon at this moment.

I saw some kind of... solution to detect the Task Manager's end task operation but this seems hacky, as in "hijacking an actual system function loaded in the program's memory area" hacky. I'm not sure it'd work when the debugger does the termination (nor the logistics of licensing a code snippet from Stack Overflow) nor if it'd be even tolerated by anti-virus software or software alike, but at least has the merit of existing.

To be fair, this is only mildly annoying, nothing worth breaking a sweat over, it's just a small papercut without any incidence over anything.

Have a nice day.

jlaumon commented 2 days ago

I've noticed it as well but couldn't repro well enough to investigate a solution. It felt like it usually failed once but the next time worked (so maybe that somehow unregistered the previous icon? I'd need to test properly).

Another option is to register an icon with a different UUID every time, but I didn't want to do that because then they accumulate in the tray.