Debugging Windows 11 Sleep Issues

How to solve Windows sleep issues like a software engineer. Learn how to debug power issues like an engineer and get to root of the problem!

Debugging Windows 11 Sleep Issues

My Windows 11 desktop PC stopped going to sleep a couple of weeks back. I don't believe I changed any settings, but I did add some new devices and installed software to work with my new Synology NAS. It's not clear what's causing this problem.

Searching online didn't go too well. Most articles just advised changing some specific power setting deep down. One even advised making changes in the Registry! Most solutions felt like they were along the lines of "...have you tried switching it on and off again...?",  doing big bang reset of all settings OR disabling power management features.

I wanted to be able to get to the bottom of the problem like a Software Engineer! I wanted to debug the issue and get to the root cause before fixing it. After some research, I found the following ways to debug the issue like an engineering bug...

  1. Use the powercfg command to see which devices can wake the computer from sleep
  2. Use the powercfg command to do a sleep study
  3. Use Windows Event Viewer to see details on which device woke the computer

1. Use the powercfg Command to See Which Devices Can Wake Up the Computer from Sleep

To check this list, you can run the following command in Windows PowerShell or Command Prompt.

powercfg -devicequery wake_armed

  • The devicequery parameter returns a list of devices that meet the specified criteria.
  • The wake_armed query flag lists devices that are currently configured to wake the system from any sleep state.

Here is what I got when I ran the command on my system...

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\*****> powercfg -devicequery wake_armed
Killer E3100G 2.5 Gigabit Ethernet Controller
HID Keyboard Device (003)
Razer Basilisk Ultimate (006)
Razer BlackWidow V3 (001)
Razer Basilisk Ultimate (007)
HID Keyboard Device (005)
Razer BlackWidow V3 (002)

PS C:\Users\*****>

Great, so this tells me, that either my keyboard or mouse can wake up the system OR the Ethernet controller! Which is interesting, since I don't connect to my home internet using the LAN card.

There are other parameters that can be passed to the devicequery option. Details can be found here.

  • wake_from_S1_supported   Returns all devices that support waking the system from a light sleep state.
  • wake_from_S2_supported   Returns all devices that support waking the system from a deeper sleep state.
  • wake_from_S3_supported   Returns all devices that support waking the system from the deepest sleep state.
  • wake_from_any   Returns all devices that support waking the system from any sleep state.
  • S1_supported   Lists devices supporting light sleep.
  • S2_supported   Lists devices supporting deeper sleep.
  • S3_supported   Lists devices supporting deepest sleep.
  • S4_supported   List devices supporting hibernation.
  • wake_programmable   Lists devices that are user-configurable to wake the system from a sleep state.
  • wake_armed   Lists devices that are currently configured to wake the system from any sleep state.
  • all_devices   Returns all devices present in the system.

2. Use the powercfg Command to do a Sleep Study

Sleep study is powerful tool that can aid in the analysis of system behavior, and which components may be preventing a platform from reaching or maintaining its lowest power state. Modern standby sleep study contains more information on the Sleep Study Report.

You can do this by issuing the following command in PowerShell...

powercfg /sleepstudy

...and open the html report that it generates. For Example...

PS C:\Users\****> powercfg /sleepstudy
Sleep Study report saved to file path C:\Users\****\sleepstudy-report.html.
PS C:\Users\****>

There is a lot of information in this report, here is just a quick screenshot of the summary.

Screenshot of the SleepStudy report
Screenshot of the SleepStudy report

3. Use Windows Event Viewer to See Details on Which Device Woke the Computer

  • Open the Start Menu and search for Event Viewer. This lets you views various Windows logs. You will have to be an Admin user to do this.
  • Navigate to Event Viewer (Local) > Windows Logs > System
  • From the right pane, click Find... and find the term "sleep"
  • You will come across various log entries, but the ones I found most interesting were the ones with Source = Power-Troubleshooter.
Screenshot of troubleshooting sleep issues in Event Viewer
Troubleshooting sleep issues in Event Viewer

As you can see in the screenshot above, the computer was taken out of sleep by a device called "Device - USB Composite Device"

You can also click the "Details" tab to get more information. For Example, here is the XML for this event...

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    <System>
          <Provider Name="Microsoft-Windows-Power-Troubleshooter" Guid="{*****}" /> 
          <EventID>1</EventID> 
          <Version>3</Version> 
          <Level>4</Level> 
          <Task>0</Task> 
          <Opcode>0</Opcode> 
          <Keywords>0x8000000000000000</Keywords> 
          <TimeCreated SystemTime="2023-03-09T19:52:40.7567621Z" /> 
          <EventRecordID>103403</EventRecordID> 
          <Correlation ActivityID="{120b1883-f376-4809-b6c7-c78e4af7e2d9}" /> 
          <Execution ProcessID="***" ThreadID="***" /> 
          <Channel>System</Channel> 
          <Computer>**********</Computer> 
          <Security UserID="********" /> 
    </System>
    <EventData>
          <Data Name="SleepTime">2023-03-09T19:49:35.0505213Z</Data> 
          <Data Name="WakeTime">2023-03-09T19:52:39.6183646Z</Data> 
          <Data Name="SleepDuration">6937</Data> 
          <Data Name="WakeDuration">1118</Data> 
          <Data Name="DriverInitDuration">1048</Data> 
          <Data Name="BiosInitDuration">2865</Data> 
          <Data Name="HiberWriteDuration">0</Data> 
          <Data Name="HiberReadDuration">0</Data> 
          <Data Name="HiberPagesWritten">0</Data> 
          <Data Name="Attributes">1912623372</Data> 
          <Data Name="TargetState">4</Data> 
          <Data Name="EffectiveState">4</Data> 
          <Data Name="WakeSourceType">5</Data> 
          <Data Name="WakeSourceTextLength">20</Data> 
          <Data Name="WakeSourceText">USB Composite Device</Data> 
          <Data Name="WakeTimerOwnerLength">0</Data> 
          <Data Name="WakeTimerContextLength">0</Data> 
          <Data Name="NoMultiStageResumeReason">0</Data> 
          <Data Name="WakeTimerOwner" /> 
          <Data Name="WakeTimerContext" /> 
          <Data Name="CheckpointDuration">12</Data> 
      </EventData>
  </Event>

I typically go down the list of all events about "sleep" to see what's going on.

Conclusion

For my specific case, the device Device - USB Composite Device came up all the time as the device that would not let the computer sleep OR would bring the computer out of sleep pretty quickly.

Given that it didn't mention the keyboard or the mouse or any kind of user input device, it had to be a USB peripheral. On my system, the additional USB devices were a Logitech Joystick (Logitech G Extreme 3D Pro) and a USB Speaker by Razer.

Searching on the internet, it turns out that there were indeed a lot of complaints about the Logitech G Extreme 3D Pro Joystick preventing computers from going to sleep! As soon as I disconnected it, problem was solved!!

Excited that I didn't have to mess with default power settings, un-install software, play around with drivers OR do some registry gymnastics.