MacBook randomly sleeps after waking

macbook propower-managementsleep-wake

My MacBook Pro often sleeps randomly after waking (the displays go dark and it either wakes itself up immediately after or has to be awoken by pressing a key).

I have noticed this happening often right after I wake up the mac, but I believe it has also happened during normal use, for no apparent reason (no key is pressed at the time the computer goes to sleep.

A few details about the MacBook:

  • The MacBook is running macOS High Sierra 10.13.1;
  • The model is MacBook Pro (15-inch, 2017);
  • An external Thunderbolt 2 display is connected via a Thunderbolt 3 to Thunderbolt 2 adapter;
  • I connect my iPhone through a USB dock which connects to the MacBook through the Thunderbolt display. I cannot confirm whether the phone was plugged in when the event happened.
  • I usually keep my MacBook connected to a power source during use, which means most if not all of these events have happened while plugged into power. These factors may not be related, however.

I managed to capture the logs from pmset -g log which I think are around the event (I cannot be sure if these logs correspond exactly to the event but looking at the log it seems to correspond to what I experienced, with the display turning off and on again immediately thereafter):

2017-11-20 19:43:49 +0100 Kernel Client Acks    Delays to Sleep notifications: [powerd is slow(5019 ms)] [UPSB driver is slow(msg: SetState to 2)(939 ms)] [AppleHPMIECS driver is slow(msg: WillChangeState to 2)(1068 ms)] [AppleIntelFramebuffer driver is slow(msg: SetState to 0)(337 ms)] [AMDFramebufferVIB driver is slow(msg: SetState to 0)(337 ms)] [IOBluetoothHostControllerUARTTransport driver is slow(msg: SetState to 0)(524 ms)]           
2017-11-20 19:43:49 +0100 Assertions            Kernel Idle sleep preventers: IODisplayWrangler          
2017-11-20 19:43:49 +0100 Notification          Display is turned on                                                                  
2017-11-20 19:43:49 +0100 Assertions            PID 193(mDNSResponder) Created MaintenanceWake "mDNSResponder:maintenance" 00:00:00  id:0x0xd00008d52 [System: PrevIdle SRPrevSleep kCPU]          
2017-11-20 19:43:49 +0100 Assertions            PID 193(mDNSResponder) Released MaintenanceWake "mDNSResponder:maintenance" 00:00:00  id:0x0xd00008d52 [System: PrevIdle]          
2017-11-20 19:43:50 +0100 Assertions            PID 120(hidd) Created UserIsActive "com.apple.iohideventsystem.queue.tickle.4294968006.3" 00:00:00  id:0x0x900008d55 [System: PrevIdle DeclUser kDisp]          
2017-11-20 19:43:51 +0100 Wake                  Wake from Normal Sleep [CDNVA] due to SPIT/UserActivity Assertion: Using AC (Charge:100%)           
2017-11-20 19:43:51 +0100 HibernateStats        hibmode=3 standbydelay=10800                                                          24            
2017-11-20 19:43:51 +0100 Kernel Client Acks    Delays to Wake notifications: [AirPort_BrcmNIC driver is slow(msg: SetState to 2)(332 ms)] [UPSB driver is slow(msg: SetState to 2)(543 ms)] [UPSB driver is slow(msg: SetState to 2)(541 ms)] [DSB0 driver is slow(msg: SetState to 2)(418 ms)] [IGPU driver is slow(msg: SetState to 2)(971 ms)] [DSB1 driver is slow(msg: SetState to 2)(417 ms)] [DSB4 driver is slow(msg: SetState to 2)(417 ms)] [HDEF driver is slow(msg: SetState to 2)(969 ms)] [GFX0 driver is slow(msg: SetState to 2)(967 ms)] [HDAU driver is slow(msg: SetState to 2)(968 ms)] [AppleHDADriver driver is slow(msg: SetState to 1)(362 ms)] [IOThunderboltController driver is slow(msg: SetState to 2)(470 ms)] [AMDFramebufferVIB driver is slow(msg: SetState to 1)(406 ms)]           
2017-11-20 19:43:51 +0100 Assertions            PID 77(powerd) Created InternalPreventSleep "com.apple.powermanagement.acwakelinger" 00:00:00  id:0x0xd00008d5c [System: PrevIdle DeclUser SRPrevSleep kCPU kDisp]          
2017-11-20 19:44:36 +0100 Assertions            PID 77(powerd) TimedOut InternalPreventSleep "com.apple.powermanagement.acwakelinger" 00:00:45  id:0x0xd00008d5c [System: PrevIdle DeclUser SRPrevSleep IPushSrvc kCPU kDisp]          
2017-11-20 19:44:36 +0100 Assertions            Summary- [System: PrevIdle DeclUser IPushSrvc kCPU kDisp] Using AC(Charge: 100)          
2017-11-20 19:44:41 +0100 Notification          Display is turned off                                                                 
2017-11-20 19:44:41 +0100 Assertions            PID 8278(nsurlsessiond) Summary PreventUserIdleSystemSleep "NSURLSessionTask 343480B1-55B5-42F3-A278-CCA8451F55B9" 00:00:01  id:0x0x100008efd [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 8278(nsurlsessiond) Summary PreventUserIdleSystemSleep "NSURLSessionTask A67299B8-E500-403A-A9AE-0B660516C995" 00:00:01  id:0x0x100008efc [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 8278(nsurlsessiond) Summary PreventUserIdleSystemSleep "NSURLSessionTask 96A26170-EBE5-4B75-9442-C0D80AE9919A" 00:00:01  id:0x0x100008efb [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 8278(nsurlsessiond) Summary PreventUserIdleSystemSleep "NSURLSessionTask 7793AA40-7D22-4697-B405-3DEF86B6FAC5" 00:00:02  id:0x0x100008ef9 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 8278(nsurlsessiond) Summary PreventUserIdleSystemSleep "NSURLSessionTask 30CBFF0F-66CF-4C2E-A877-C55D17EE203C" 00:00:02  id:0x0x100008ef8 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 8278(nsurlsessiond) Summary PreventUserIdleSystemSleep "NSURLSessionTask CF6B6089-B198-4977-93D9-9674CA909A5B" 00:00:02  id:0x0x100008ef7 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 163(coreaudiod) Summary PreventUserIdleSystemSleep "com.apple.audio.AppleHDAEngineOutput:1F,3,0,1,1:0.context.preventuseridlesleep" 00:00:06  id:0x0x100008eb8 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 8585(AddressBookSourceSync) Summary PreventUserIdleSystemSleep "Address Book Source Sync" 00:00:26  id:0x0x100008e62 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 120(hidd) Summary UserIsActive "com.apple.iohideventsystem.queue.tickle.4294968221.3" 00:00:00  id:0x0x900008d55 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 8261(UserEventAgent) Summary BackgroundTask "com.apple.tourist.notify" 00:00:12  id:0x0xb00008e9e [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 8261(UserEventAgent) Summary BackgroundTask "com.apple.silhouette.compute" 00:00:16  id:0x0xb00008e94 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 8261(UserEventAgent) Summary BackgroundTask "com.apple.photoanalysisd.backgroundanalysis" 00:00:17  id:0x0xb00008e93 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 88(mds) Summary BackgroundTask "com.apple.metadata.mds.power" 00:00:18  id:0x0xb00008e91 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 8261(UserEventAgent) Summary BackgroundTask "com.apple.photolibraryd.maintenance" 00:00:21  id:0x0xb00008e8c [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 8261(UserEventAgent) Summary BackgroundTask "com.apple.AddressBook.ScheduledSync" 00:00:26  id:0x0xb00008e64 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 8261(UserEventAgent) Summary BackgroundTask "com.apple.routined.learnedLocationEngine.train" 00:00:33  id:0x0xb00008de9 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 248(mds_stores) Summary BackgroundTask "com.apple.metadata.mds_stores.power" 00:00:38  id:0x0xb00008d9a [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 101(apsd) Summary ApplePushServiceTask "com.apple.apsd-login" 00:00:38  id:0x0xb00008d99 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 668(softwareupdate_notify_agent) Summary BackgroundTask "com.apple.softwareupdate.NotifyAgentAssertion-UpdatesAvailable" 00:00:46  id:0x0xb00008d7d [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 101(apsd) Summary InteractivePushServiceTask "com.apple.apsd-outgoingmessage" 00:00:29  id:0x0x1200008e2f [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            PID 101(apsd) Summary InteractivePushServiceTask "com.apple.apsd-recreatecourierstate-push.apple.com" 00:00:06  id:0x0x1200008ebf [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:41 +0100 Assertions            Kernel Idle sleep preventers: -None-          
2017-11-20 19:44:41 +0100 Assertions            PID 120(hidd) TurnedOn UserIsActive "com.apple.iohideventsystem.queue.tickle.4294968228.11" 00:00:00  id:0x0x900008d55 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:42 +0100 Assertions            PID 120(hidd) TurnedOn UserIsActive "com.apple.iohideventsystem.queue.tickle.4294968228.11" 00:00:00  id:0x0x900008d55 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:42 +0100 Assertions            PID 120(hidd) TurnedOn UserIsActive "com.apple.iohideventsystem.queue.tickle.4294968228.11" 00:00:00  id:0x0x900008d55 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:44:42 +0100 Assertions            Kernel Idle sleep preventers: IODisplayWrangler          
2017-11-20 19:44:42 +0100 Notification          Display is turned on                                                                  
2017-11-20 19:44:54 +0100 Assertions            PID 668(softwareupdate_notify_agent) Released BackgroundTask "com.apple.softwareupdate.NotifyAgentAssertion-UpdatesAvailable" 00:01:00  id:0x0xb00008d7d [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:45:14 +0100 Assertions            PID 8585(AddressBookSourceSync) Released PreventUserIdleSystemSleep "Address Book Source Sync" 00:01:00  id:0x0x100008e62 [System: PrevIdle DeclUser kDisp]          
2017-11-20 19:45:14 +0100 Assertions            PID 8261(UserEventAgent) Released BackgroundTask "com.apple.AddressBook.ScheduledSync" 00:01:00  id:0x0xb00008e64 [System: PrevIdle DeclUser kDisp]          
2017-11-20 19:45:41 +0100 Assertions            PID 101(apsd) Released ApplePushServiceTask "com.apple.apsd-login" 00:01:39  id:0x0xb00008d99 [System: PrevIdle DeclUser IPushSrvc kCPU kDisp]          
2017-11-20 19:46:07 +0100 Assertions            PID 8490(sharingd) Released PreventUserIdleSystemSleep "Handoff" 00:01:07  id:0x0x100008fda [System: PrevIdle DeclUser kDisp]          
2017-11-20 19:46:22 +0100 Assertions            PID 248(mds_stores) Released BackgroundTask "com.apple.metadata.mds_stores.power" 00:02:19  id:0x0xb00008d9a [System: PrevIdle DeclUser kDisp]          
2017-11-20 19:46:30 +0100 Assertions            PID 88(mds) Released BackgroundTask "com.apple.metadata.mds.power" 00:02:06  id:0x0xb00008e91 [System: PrevIdle DeclUser kDisp]          
2017-11-20 19:46:47 +0100 Assertions            PID 8077(backupd) ClientDied PreventUserIdleSystemSleep "Time Machine backup" 01:37:21  id:0x0x100008c55 [System: PrevIdle DeclUser kDisp]          
2017-11-20 19:46:47 +0100 Assertions            PID 8077(backupd) ClientDied BackgroundTask "Time Machine backup" 01:37:21  id:0x0xb00008c54 [System: PrevIdle DeclUser kDisp]          
2017-11-20 19:46:52 +0100 Assertions            PID 8261(UserEventAgent) Released BackgroundTask "com.apple.photoanalysisd.backgroundanalysis" 00:02:28  id:0x0xb00008e93 [System: PrevIdle DeclUser kDisp]          

EDIT: 2 other instances of the same issue:

2017-11-28 19:39:50 +0100 Assertions            PID 97671(backupd) ClientDied PreventUserIdleSystemSleep "Time Machine backup" 00:03:47  id:0x0x1000098ca [System: DeclUser kDisp]
2017-11-28 19:39:50 +0100 Assertions            PID 97671(backupd) ClientDied BackgroundTask "Time Machine backup" 00:03:47  id:0x0xb000098c9 [System: DeclUser kDisp]
2017-11-28 19:39:51 +0100 Notification          Display is turned off
2017-11-28 19:39:51 +0100 Assertions            PID 119(hidd) Summary UserIsActive "com.apple.iohideventsystem.queue.tickle.4295043186.11" 00:01:06  id:0x0x9000098d9 [System: DeclUser kDisp]
2017-11-28 19:39:51 +0100 Assertions            Kernel Idle sleep preventers: -None-
2017-11-28 19:39:55 +0100 Assertions            PID 119(hidd) TurnedOn UserIsActive "com.apple.iohideventsystem.queue.tickle.4294968006.3" 00:00:00  id:0x0x9000098d9 [System: DeclUser kDisp]
2017-11-28 19:39:55 +0100 Assertions            Kernel Idle sleep preventers: IODisplayWrangler
2017-11-28 19:39:55 +0100 Notification          Display is turned on

2017-12-08 20:44:30 +0100 Assertions            PID 56882(backupd) ClientDied PreventUserIdleSystemSleep "Time Machine backup" 01:03:41  id:0x0x100008d0c [System: PrevIdle DeclUser kDisp]
2017-12-08 20:44:30 +0100 Assertions            PID 56882(backupd) ClientDied BackgroundTask "Time Machine backup" 01:03:41  id:0x0xb00008d0b [System: PrevIdle DeclUser kDisp]
2017-12-08 20:46:03 +0100 Notification          Display is turned off
2017-12-08 20:46:03 +0100 Assertions            PID 8170(sharingd) Summary PreventUserIdleSystemSleep "Handoff" 00:02:55  id:0x0x100008e08 [System: PrevIdle DeclUser kDisp]
2017-12-08 20:46:03 +0100 Assertions            PID 119(hidd) Summary UserIsActive "com.apple.iohideventsystem.queue.tickle.4295674301.11" 00:00:30  id:0x0x900008add [System: PrevIdle DeclUser kDisp]
2017-12-08 20:46:03 +0100 Assertions            Kernel Idle sleep preventers: -None-
2017-12-08 20:46:05 +0100 Assertions            PID 119(hidd) TurnedOn UserIsActive "com.apple.iohideventsystem.queue.tickle.4295674290.3" 00:00:00  id:0x0x900008add [System: PrevIdle DeclUser kDisp]
2017-12-08 20:46:05 +0100 Assertions            Kernel Idle sleep preventers: IODisplayWrangler
2017-12-08 20:46:05 +0100 Notification          Display is turned on
2017-12-08 20:46:06 +0100 Assertions            PID 8170(sharingd) Released PreventUserIdleSystemSleep "Handoff" 00:02:59  id:0x0x100008e08 [System: PrevIdle DeclUser kDisp]

Total Sleep/Wakes since boot at 2017-12-02 11:41:35 +0100 :228

2017-12-08 20:46:17 +0100 : Showing all currently held IOKit power assertions
Assertion status system-wide:
   BackgroundTask                 0
   ApplePushServiceTask           0
   UserIsActive                   1
   PreventUserIdleDisplaySleep    0
   PreventSystemSleep             0
   ExternalMedia                  0
   PreventUserIdleSystemSleep     0
   NetworkClientActive            0
Listed by owning process:
   pid 119(hidd): [0x00021dbf00098add] 00:00:02 UserIsActive named: "com.apple.iohideventsystem.queue.tickle.4295674301.11"
    Timeout will fire in 898 secs Action=TimeoutActionRelease
Kernel Assertions: 0x2c=USB,BT-HID,THNDR
   id=503  level=255 0x20=THNDR mod=08/12/2017, 8:46 PM description=NHI0 owner=AppleThunderboltHAL
   id=682  level=255 0x8=BT-HID mod=01/01/1970, 1:00 AM description=com.apple.driver.IOBluetoothHIDDriver owner=AppleHSBluetoothDevice
   id=843  level=255 0x4=USB mod=01/01/1970, 1:00 AM description=com.apple.usb.externaldevice.00100000 owner=ASM107x
   id=845  level=255 0x4=USB mod=01/01/1970, 1:00 AM description=com.apple.usb.externaldevice.00300000 owner=ASM107x
Idle sleep preventers: IODisplayWrangler

Best Answer

The first things I'd try are resetting both the NVRAM and SMC.

Before following the steps below, ensure you have no external hardware connected and that you're using the built-in keyboard.

Resetting the NVRAM on a 2017 MacBook Pro model

To reset the NVRAM on all 2017 MacBook Pro models (with and without Touch Bar) follow these steps:

  1. Shut down your MBP. Yes, a full shut down, not just logging out.
  2. Press the power button and then immediately press the commandoptionpr keys.
  3. Keep these keys pressed down for at least 20 seconds!
  4. Let go of the keys and let your MBP reboot normally.

Note: When you log back in you may need to readjust some of your system preferences (e.g. speaker volume, screen resolution, startup disk selection, time zone information, etc).

Reset the SMC

There's a couple of ways you can reset the SMC on your MBP, however I prefer the following steps:

  1. Shut down your MBP
  2. Keep the power cable plugged in
  3. Press at the same time shiftoptioncontrol (on the left side of the keyboard) and the power button and keep these keys down for at least 10 seconds
  4. Let go
  5. Turn your computer back on with the power button

After resetting both the NVRAM and SMC, use your MBP to determine if the problem still occurs. Let me know how you go.