nefares / Background-Muter

Background Muter - Automatically Mute Background Applications
GNU General Public License v3.0
83 stars 8 forks source link

WinBGMute seems to "go to sleep" after an undefined period of time #30

Closed mercster closed 8 months ago

mercster commented 1 year ago

After a few hours it seems, WinBGMute will "go to sleep" and stop actively muting/unmuting windows as they get/lose focus. Hard to define when this happens, as it would require dedicated testing over several hours, which I have not done. I also note noone else has posted this issue, so I'm not sure. I have all power management off on my machine... I never sleep, hibernate, or otherwise allow my PC to go into a low power situation. I can tell when this happens because I notice it, I will put a window in the background and it is not muted. If I go to where WinBGMute is minimized in the system tray and open the window, it instantly "springs to life" and starts working again. It takes awhile for it to happen, but it does happen. Sorry I can't give any steps to reproduce.

Windows 11 fully patched x86-64 Latest WinBGMute

nefares commented 1 year ago

Hmm that is a strange behavior. I'll keep an eye on it when that happens on my machine.

The next time that happens and before reopening Background-Muter, could you check the following:

Then after you reopen Background-Muter, please copy the log from the log window and paste it here.

A possible fix is to run Background-Muter as an Administrator and check if the problem persists.

If this keeps happening, maybe windows is interfering with the utility somehow. It could also be a win11 issue but I'm not sure what's causing it. Maybe an upgrade of the whole project to dotnet 7 or dotnet 8 can fix this.

mercster commented 1 year ago

Yeah, that gives me some things to do... I will catch myself next time and look at the process list next time to see if anything looks iffy. And will make sure to copy/paste log. Admin rights is another idea, but if I can I'd like to track this down for you. Will keep a look out, thanks.

mercster commented 11 months ago

Hello there,

OK so it happened to me last night. I could tell it wasn't muting a game I was playing while it was in the background. Before raising it from the notification area, I checked it in Process list. Status was "Running", not Suspended or anything else.

I went into the notification area, the icon was there. When I clicked it to bring up the window, the game (which was in the background obviously) instantly muted and the WinBGMute UI came up. The log was very short:

Setting autostart @C:\Users\merc\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup -> Background Muter.lnk
[+] Summary: skipped () and muted (SpotifyWidgetProvider, PowerToys.Peek.UI, steam, ShellExperienceHost, [PROCESS NAME REDACTED)
[+] Foreground process changed to chrome - 11968
[+] Summary: skipped () and muted (SpotifyWidgetProvider, PowerToys.Peek.UI, steam, ShellExperienceHost, PROCESS NAME REDACTED, )
[+] Foreground process changed to explorer - 7296

I removed the game name, but it was just the name of the application and what I assume to be a thread label of some sort. The first line is curious, as if it was just started when I "brought it back to life" via the notification area icon. It was definitely running and in the process list, but the log seems to have started just as I re-awakened it. There are no timestamps in the log, those might be a profitable addition? Anyway... yeah, nothing I see outwardly that would let me know what's happening.

Hard for me to know exactly when the behavior started anyway, as... well, I am not constantly putting applications with sound output in the background (and those that I do, for instance Chrome, are in the exception lists.)

EDIT: Should note that this is not just happening with one weird game/program... I notice it happening from time to time with various programs. This is incredibly hard to test of course in a structured way.

EDIT2: Thoughts going forward... is there a switch I can give the program to enable more verbose logging? And is there a log on-disk somewhere? (I copied the above from the GUI widget that displays the log.)

mercster commented 11 months ago

Happened again... I could tell it was not "working", although the process was Running in task list, and the icon was in the notification tray. Double click the icon, window pops up and instantly mutes everything in the background, and acts like it just started:

Setting autostart @C:\Users\merc\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup -> Background Muter.lnk [+] Summary: skipped (chrome, Discord, ) and muted (steam, PowerToys.Peek.UI, SpotifyWidgetProvider, Idle, nwmain, ) [+] Foreground process changed to nwmain - 3372 [+] Unmuting foreground process nwmain(3372) . [+] Summary: skipped (chrome, Discord, ) and muted (steam, PowerToys.Peek.UI, SpotifyWidgetProvider, Idle, ) [+] Foreground process changed to explorer - 7976 [+] Summary: skipped (chrome, Discord, ) and muted (steam, PowerToys.Peek.UI, SpotifyWidgetProvider, Idle, nwmain, ) [+] Summary: skipped (chrome, Discord, ) and muted (steam, PowerToys.Peek.UI, SpotifyWidgetProvider, Idle, nwmain, ) [+] Foreground process changed to nwmain - 3372 [+] Unmuting foreground process nwmain(3372) . [+] Summary: skipped (chrome, Discord, ) and muted (steam, PowerToys.Peek.UI, SpotifyWidgetProvider, Idle, ) [+] Foreground process changed to WinBGMuter - 18236 [+] Summary: skipped (chrome, Discord, ) and muted (steam, PowerToys.Peek.UI, SpotifyWidgetProvider, Idle, nwmain, )

It should be noted this only happens after quite a few hours of not using the computer. I don't have any power saving/etc turned on, but sometimes I will keep the computer on for 20+ hours (I usually reboot around once a day, but this seems to happen definitely after a good amount of time the box has been on.) It seems to be that WinBGMute is putting itself to sleep, or Windows is doing it, not sure. Maybe there's a keepalive you can run every hour or so, if there's no Windows being moved around (for instance, if I am asleep, that's a good 8-10 hours it doesn't have anything to "do", maybe Windows tries to put it into a background process that makes it non-functional or something. But have to reiterate, it is "Running" in process list, not sleep mode or anything.)

Kaiji-Kun commented 9 months ago

Same thing has been happening to me on fully patched Windows 11 x64. Bringing Background-Muter to the foreground solves the problem as you mentioned but it's annoying because it happens at least once daily. I hope a fix is possible.

nefares commented 9 months ago

Hi , apologies the answer took a bit long, I did not have access to my computer for a while.

Thanks @mercster for the detailed feedback and testing.

I implemented the following changes:

I'm still not sure what is actually happening... I haven't found anything related to this on MSDN... It does seem related to idleness of Windows/Window-Switching. I hope the new changes can provide more insight on this.

Please use the pre-release v1.0.9: https://github.com/nefares/Background-Muter/releases/tag/v1.0.9

Again your input is valuable on this, feel free to comment once you had a chance to test this.

Kaiji-Kun commented 8 months ago

It's been working perfectly for the last 48 hours. No need to bring the process to the foreground. Thanks for this fix!

mercster commented 8 months ago

Can't test ATM as I am on a Linux kick (once a year I switch from Linux to Windows, or Windows to Linux, and stay there for about a year. I run one until it pisses me off enough, then switch back and repeat) but thanks for your continued work on this, and I am sure when I run Windows sometime in the future as my main OS I will look forward to testing the fix! Glad I could help with the bug report. Cheers, Merry Christmas. :+1:

mercster commented 8 months ago

(On that note I have attempted to write a script that does what WinBGMute does for Linux, but it requires more knowledge than I possess about the ever-changing sound backend/daemons that Linux uses, and have come up short.)

nefares commented 8 months ago

Thanks to you both the feedback! Will close the issue as it seems to be fixed for now.

A linux port of the tool could be interesting. I have added the feature #31 in case @mercster you want to document some of your efforts.

Happy holidays!