Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto Dark Mode prevents system from going to sleep #317

Closed
shadeMe opened this issue Oct 16, 2021 · 7 comments
Closed

Auto Dark Mode prevents system from going to sleep #317

shadeMe opened this issue Oct 16, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@shadeMe
Copy link

shadeMe commented Oct 16, 2021

Description
Having the Auto Dark Mode service running in the background prevents Windows from going to sleep. I've had this issue for quite some time now (system not going to sleep) but didn't manage to figure out what was causing it until just now.

Strangely enough, nothing shows up in the system logs or powercfg /requests that would indicate that that the service was the root cause.

Expected behavior
The system automatically goes to sleep as configured in the Windows power management settings.

Log Data
service.log

Commit Hash and Version
Screenshot 2021-10-17 012051
Screenshot 2021-10-17 012131

@shadeMe shadeMe added the bug Something isn't working label Oct 16, 2021
@Spiritreader
Copy link
Member

Spiritreader commented Oct 17, 2021

Hello! Thank you for your report, thank you for following the bug template, and thank you for providing all the log files.
Because of this, I am immediately able to provide a fix for you.

Why the bug occurred

After every theme application, Auto Dark Mode retrieves the current theme from a windows API endpoint.
What's happening is that Windows is mis-reporting the theme you have configured even after it has been set by ADM.

For some reason, that endpoint's return value is not matching the current Windows theme, even though it was reported as applied correctly.
As such, Auto Dark Mode infinitely tries to apply your theme on every tick, which keeps Windows awake as it makes calls to an API that itself keeps your system awake. This is merely a side effect of an API issue, Auto Dark Mode does nothing directly that prevents sleep.

I am unsure what is causing this behavior and have seen it on some computers, including mine, but not to that extent (goes away on its own within minutes. Basically, the Windows API never returns the correct theme path in your case.
I'm pretty sure you did nothing to actively cause this. My suspicion is that Windows internally can't apply that theme file directly, and instead creates a Custom.theme file. That name of course wouldn't match.
(I also had this happen quite a while ago, but the API started returning the right values again at some point and the issue never re-surfaced. So I thought of it as Windows hiccup.)
This could also be connected to #192 in some way.

How to fix it

In the newer Auto Dark Mode betas, there is already an option availalbe to disable theme validation.
I have removed the validation check after ADM applies the theme in the theme handler. This means:
Disabling this option in the screenshot below in Beta build 10.0.1.51 or newer should fix this for you.
The mentioned version should be available to you within 5 minutes of this post.

image

@shadeMe
Copy link
Author

shadeMe commented Oct 17, 2021

Thanks very much for the quick response! The new beta build appears to have fixed the sleep issue but also seems to have introduced a regression - Automatic theme switching doesn't seem to work any more. Nor does it work when I force the theme from the system tray.

Log: service.log

@Spiritreader
Copy link
Member

Hmm I am unable to reproduce this.
Can you attach your config file again?

@shadeMe
Copy link
Author

shadeMe commented Oct 17, 2021

config.yaml.txt

Spiritreader added a commit that referenced this issue Oct 17, 2021
- less strict switch criteria in theme manager
- improve force theme with disabled monitor
- add debug logging to disabled active monitor state
- unrelated: improve tray icon hide message
@Spiritreader
Copy link
Member

Spiritreader commented Oct 17, 2021

Please try again with Beta 0.1.52.
I've done multiple changes to make the theme switching logic less strict with when it is allowed to switch.

If it still doesn't work, please open the config file, enable the Debug flag under the Tunable section, delete the service.log file, restart the service and post the entire output after attempting to switch themes automatically and manually.

@shadeMe
Copy link
Author

shadeMe commented Oct 17, 2021

That seems to have done the trick! Thanks again for the lightning-fast turn-around on this issue :) I'll keep an eye out for any other bugs.

PS: I hope that the Paypal link displayed in-app sends the proceeds to both developers (I didn't want to set up a GitHub Sponsers account).

@shadeMe shadeMe closed this as completed Oct 17, 2021
@Spiritreader
Copy link
Member

That seems to have done the trick! Thanks again for the lightning-fast turn-around on this issue :) I'll keep an eye out for any other bugs.

PS: I hope that the Paypal link displayed in-app sends the proceeds to both developers (I didn't want to set up a GitHub Sponsers account).

Awesome! Glad it works now!
Yes it indeed is. We share incoming donations!
Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants