Diagnosing bugs preventing sleep on Windows
Published on: 2025-05-08 11:40:33
TL;DR: Diagnosing programs causing insomnia is quite straightforward on Windows.
My employer has a policy set for Windows machines which locks each computer automatically after some inactivity. One of my colleagues noticed that if they have recent builds of our product running in the background, this auto-locking does not take effect. I was asked to investigate.
The bug itself got pretty low priority, as at first glance the phenomenon does not seem to cause that much trouble. I did not know anything about how all this works on Windows, but I had a hunch that if the lock screen is being prevented, chances are that the computer going to sleep gets the same treatment. This is a much bigger issue, as it might have a huge impact on the battery life of notebooks.
Breakpoints
The repro was pretty straightforward (launch the program, then wait X minutes, and note how the lock screen did not appear), and I also had the source code for the software being investigated, so my first intuition w
... Read full article.