With Power Nap off, what causes MacBook Pro 2018 battery drain with lid closed and wake-ups every 2 hours?

Solution 1:

There were two different settings I had to fiddle with to get the computer to go into standby mode when I wanted it to, without periodic wakeups. This doesn't mean the battery drain issue was solved, though; I suggest reading the "Ongoing battery drain issues" section near the end of the answer for an explanation.

For those interested only in this partial fix, here are the commands to issue in Terminal:

$ sudo pmset -b tcpkeepalive 0
$ sudo pmset -b standbydelaylow 3600
$ sudo pmset -b standbydelayhigh 3600

TCPKeepAliveDuringSleep

First. I found TCPKeepAliveDuringSleep with the help of this. It is on by default in my hardware:

$ ioreg -l | grep IOPlatformFeatureDefaults
    | | |   "IOPlatformFeatureDefaults" = {"TCPKeepAliveDuringSleep"=Yes,"DNDWhileDisplaySleeps"=No,"TCPKeepAliveExpirationTimeout"=43200,"NotificationWake"=Yes}

The timeout is 43200 seconds (exactly 12 hours), and as can be seen in the log, the computer woke up every 2 hours and a few seconds after the first at July 3rd 18:10, but not anymore after 12 hours (i.e. no wakeups at July 4th 6:12). The same thing happened from July 4th to July 5th: first wakeup at July 4th 18:48 and then one every 2 hours and a few seconds, but no wakeup at July 5th 6:49.

This may explain why the computer never went into standby mode, since it is configured to do so after 3 hours, but TCPKeepAliveDuringSleep was waking it up every 2 hours.

Now onto an attempted fix.

Confirming the TCPKeepAlive setting hasn't been fiddled with (the command was run while on battery):

$ pmset -g
System-wide power settings:
Currently in use:
 standbydelaylow      10800
 standby              1
 halfdim              1
 hibernatefile        /var/vm/sleepimage
 proximitywake        0
 powernap             0
 gpuswitch            2
 disksleep            10
 standbydelayhigh     86400
 sleep                3 (sleep prevented by sharingd)
 hibernatemode        3
 ttyskeepawake        1
 displaysleep         3
 tcpkeepalive         1
 highstandbythreshold 50
 acwake               0
 lidwake              1

Note tcpkeepalive 1 near the end.

I ran this command to disable it:

$ sudo pmset -b tcpkeepalive 0
Password:
Warning: This option disables TCP Keep Alive mechanism when sytem is sleeping. This will result in some critical features like 'Find My Mac' not to function properly.

I ran pmset -g again to make sure the setting was indeed changed:

$ pmset -g
System-wide power settings:
Currently in use:
 standbydelaylow      10800
 standby              1
 halfdim              1
 hibernatefile        /var/vm/sleepimage
 proximitywake        0
 powernap             0
 gpuswitch            2
 disksleep            10
 standbydelayhigh     86400
 sleep                3 (sleep prevented by sharingd)
 hibernatemode        3
 ttyskeepawake        1
 displaysleep         3
 tcpkeepalive         0
 highstandbythreshold 50
 acwake               0
 lidwake              1

standbydelaylow and standbydelayhigh

While disabling TCPKeepAliveDuringSleep made sure the wakeups every 2 hours were gone, the computer appeared not to go into standby mode for 24 hours, draining the battery in the meanwhile.

From the test made after disabling TCPKeepAliveDuringSleep, battery was down from 62% charge to, allegedly, 51% at the end, about 37.5 hours after closing the lid (in truth, I checked the battery percentage right after opening the lid and it was at 43%).

The log shows the computer woke up a few times: 12 hours after closing the lid; 20 hours after closing the lid; and finally 24 hours after closing the lid. To simplify parsing the logs, here are the sleep and wake events filtered from the log:

2019-07-05 18:58:49 -0300 Sleep                 Entering Sleep state due to 'Clamshell Sleep':TCPKeepAlive=disabled Using Batt (Charge:62%) 43208 secs
2019-07-06 06:58:57 -0300 DarkWake              DarkWake from Normal Sleep [CDN] due to EC.RTC/SleepService: Using BATT (Charge:58%) 0 secs
2019-07-06 06:58:57 -0300 Sleep                 Entering Sleep state due to 'Sleep Service Back to Sleep':TCPKeepAlive=disabled Using Batt (Charge:58%) 28806 secs
2019-07-06 14:59:03 -0300 DarkWake              DarkWake from Normal Sleep [CDN] due to EC.RTC/SleepService: Using BATT (Charge:53%) 0 secs
2019-07-06 14:59:03 -0300 Sleep                 Entering Sleep state due to 'Sleep Service Back to Sleep':TCPKeepAlive=disabled Using Batt (Charge:53%) 14423 secs
2019-07-06 18:59:26 -0300 DarkWake              DarkWake from Normal Sleep [CDN] due to EC.SleepTimer/SleepTimer: Using BATT (Charge:51%) 0 secs
2019-07-06 18:59:26 -0300 Sleep                 Entering Sleep state due to 'Maintenance Sleep':TCPKeepAlive=disabled Using Batt (Charge:51%) 48731 secs
2019-07-07 08:31:37 -0300 Wake                  Wake from Standby [CDNVA] due to EC.LidOpen/Lid Open: Using BATT (Charge:51%)

Fiddling some more, I was able to control exactly when the computer goes into standby mode. For this, one needs to run pmset -a standbydelaylow 3600 and pmset -a standbydelayhigh 3600, replacing 3600 by the desired time in seconds.

Originally, standbydelaylow was 10800, and hence it should take 3 hours to go into standby mode. However, standbydelayhigh was 86400 (24 hours) and the battery charge was high enough (this controlled by the highstandbythreshold parameter of pmset, which is 50% in my case) that the computer would wait for 24 hours before going into standby mode.

Setting both standbydelaylow and standbydelayhigh to the same value solves the problem.

Here's the output from another long (42 hours) sleep, after this setting was changed:

Time stamp                Domain                Message                                                                     Duration    Delay
==========                ======                =======                                                                     ========    =====
UUID: 58E38EDD-2A6C-418F-826A-4B11FE80D4C2
2019-07-13 13:28:37 -0300 Notification          Display is turned off
2019-07-13 13:28:37 -0300 Assertions            PID 345(sharingd) Summary PreventUserIdleSystemSleep "Handoff" 00:00:24  id:0x0x10000857e [System: PrevIdle DeclUser kDisp]
2019-07-13 13:28:37 -0300 Assertions            PID 60(TeamViewer_Service) Summary UserIsActive "TeamViewer user activity" 00:00:23  id:0x0x900008582 [System: PrevIdle DeclUser kDisp]
2019-07-13 13:28:37 -0300 Assertions            PID 110(hidd) Summary UserIsActive "com.apple.iohideventsystem.queue.tickle.4295090251.11" 00:00:06  id:0x0x90000846a [System: PrevIdle DeclUser kDisp]
2019-07-13 13:28:37 -0300 Assertions            PID 84(apsd) Summary ApplePushServiceTask "com.apple.apsd-waitingformessages-push.apple.com" 00:00:11  id:0x0xb000085a3 [System: PrevIdle DeclUser kDisp]
2019-07-13 13:28:37 -0300 Assertions            Kernel Idle sleep preventers: -None-
2019-07-13 13:28:37 -0300 Assertions            PID 345(sharingd) Released PreventUserIdleSystemSleep "Handoff" 00:00:24  id:0x0x10000857e [System: PrevIdle DeclUser kDisp]
2019-07-13 13:28:37 -0300 Assertions            PID 59(powerd) Created InternalPreventSleep "com.apple.powermanagement.darkwakelinger" 00:00:00  id:0x0xd000085ac [System: PrevIdle DeclUser SRPrevSleep kCPU kDisp]
2019-07-13 13:28:52 -0300 Assertions            PID 59(powerd) TimedOut InternalPreventSleep "com.apple.powermanagement.darkwakelinger" 00:00:15  id:0x0xd000085ac [System: DeclUser SRPrevSleep kCPU kDisp]
2019-07-13 13:28:52 -0300 Sleep                 Entering Sleep state due to 'Clamshell Sleep':TCPKeepAlive=disabled Using Batt (Charge:26%) 3621 secs
2019-07-13 13:28:54 -0300 Assertions            PID 84(apsd) Released ApplePushServiceTask "com.apple.apsd-waitingformessages-push.apple.com" 00:00:28  id:0x0xb000085a3 [System: DeclUser kDisp]
2019-07-13 13:29:07 -0300 Assertions            PID 84(apsd) Released InteractivePushServiceTask "com.apple.apsd-requestkeepaliveproxy-push.apple.com" 00:00:15  id:0x0x12000085c5 [System: DeclUser kDisp]
2019-07-13 13:29:09 -0300 PM Client Acks        Delays to Sleep notifications: [com.apple.apsd is slow(17016 ms)]
2019-07-13 14:29:12 -0300 Kernel Client Acks    Delays to Sleep notifications: [AppleIntelFramebuffer driver is slow(msg: SetState to 1)(1585 ms)] [powerd is slow(17022 ms)] [UPSB driver is slow(msg: SetState to 2)(942 ms)] [UPSB driver is slow(msg: SetState to 2)(941 ms)] [AppleHPMIECS driver is slow(msg: WillChangeState to 2)(1063 ms)] [AppleHPMIECS driver is slow(msg: WillChangeState to 2)(1064 ms)] [AppleUSBVHCIBCE driver is slow(msg: SetState to 1)(325 ms)] [RP01 driver is slow(msg: SetState to 0)(1008 ms)]
2019-07-13 14:29:12 -0300 Assertions            PID 184(mDNSResponder) Created MaintenanceWake "mDNSResponder:maintenance" 00:00:00  id:0x0xd000085cd [System: DeclUser kDisp]
2019-07-13 14:29:12 -0300 Assertions            PID 184(mDNSResponder) Released MaintenanceWake "mDNSResponder:maintenance" 00:00:00  id:0x0xd000085cd [System: DeclUser kDisp]
2019-07-13 14:29:13 -0300 DarkWake              DarkWake from Normal Sleep [CDN] due to EC.SleepTimer/SleepTimer: Using BATT (Charge:25%) 0 secs
2019-07-13 14:29:13 -0300 HibernateStats        hibmode=3 standbydelay=3600                                                           rd=788 ms
2019-07-13 14:29:13 -0300 WakeTime              WakeTime: 2.253 sec
2019-07-13 14:29:13 -0300 Kernel Client Acks    Delays to Wake notifications: [UPSB driver is slow(msg: SetState to 2)(540 ms)] [UPSB driver is slow(msg: SetState to 2)(540 ms)] [ADIO driver is slow(msg: SetState to 2)(537 ms)] [AMDFramebufferVIB driver is slow(msg: SetState to 1)(383 ms)]
2019-07-13 14:29:13 -0300 Sleep                 Entering Sleep state due to 'Maintenance Sleep':TCPKeepAlive=disabled Using Batt (Charge:25%) 150908 secs
2019-07-13 14:29:22 -0300 PM Client Acks        Delays to Sleep notifications: [com.apple.apsd is slow(1001 ms)] [AirPort configd plug-in is slow(9213 ms)]
2019-07-15 08:24:21 -0300 Kernel Client Acks    Delays to Sleep notifications: [powerd is slow(9218 ms)] [AppleIntelFramebuffer driver is slow(msg: SetState to 0)(343 ms)] [AMDFramebufferVIB driver is slow(msg: SetState to 0)(342 ms)] [AVExFramebuffer driver is slow(msg: SetState to 0)(343 ms)] [AppleUSBVHCIBCE driver is slow(msg: SetState to 1)(320 ms)] [RP01 driver is slow(msg: SetState to 0)(1006 ms)] [UPSB driver is slow(msg: SetState to 2)(546 ms)] [UPSB driver is slow(msg: SetState to 2)(545 ms)] [ADIO driver is slow(msg: SetState to 2)(550 ms)] [AMDFramebufferVIB driver is slow(msg: SetState to 1)(402 ms)]
2019-07-15 08:24:21 -0300 Assertions            PID 59(powerd) Created InternalPreventSleep "Holding in darkwake for up to 30 seconds to update inactivity prediction" 00:00:00  id:0x0xd000085d9 [System: DeclUser SRPrevSleep kCPU kDisp]
2019-07-15 08:24:21 -0300 Assertions            PID 59(powerd) Created InternalPreventSleep "PM configd - Wait for Device enumeration" 00:00:00  id:0x0xd000085da [System: DeclUser SRPrevSleep kCPU kDisp]
2019-07-15 08:24:21 -0300 DarkWake              DarkWake from Standby [CDN] due to EC.ACAttach/HID Activity: Using BATT (Charge:25%) 0 secs
2019-07-15 08:24:21 -0300 HibernateStats        hibmode=3 standbydelay=3600                                                           rd=788 ms
2019-07-15 08:24:21 -0300 WakeTime              WakeTime: 4.639 sec
2019-07-15 08:24:21 -0300 Assertions            Summary- [System: DeclUser SRPrevSleep kCPU kDisp] Using AC(Charge: 7)
2019-07-15 08:24:21 -0300 Notification          Display is turned on
2019-07-15 08:24:21 -0300 Assertions            PID 1144(PowerChime) Created DisplayWake "com.apple.chimeOnAttach" 00:00:00  id:0x0xe000085dc [System: DeclUser SRPrevSleep DispWake kCPU kDisp]
2019-07-15 08:24:21 -0300 Assertions            PID 84(apsd) Released ApplePushServiceTask "com.apple.apsd-connectionestablish-push.apple.com" 41:55:05  id:0x0xb000085d5 [System: DeclUser SRPrevSleep DispWake kCPU kDisp]
2019-07-15 08:24:21 -0300 Assertions            Kernel Idle sleep preventers: IODisplayWrangler
2019-07-15 08:24:21 -0300 Wake                  DarkWake to FullWake from Standby [CDNVA] due to Notification: Using AC (Charge:7%)
2019-07-15 08:24:21 -0300 HibernateStats        hibmode=3 standbydelay=3600                                                           rd=788 ms
2019-07-15 08:24:21 -0300 WakeTime              WakeTime: 0.194 sec
2019-07-15 08:24:21 -0300 Assertions            PID 184(mDNSResponder) Created MaintenanceWake "mDNSResponder:maintenance" 00:00:00  id:0x0xd000085de [System: DeclUser SRPrevSleep DispWake kCPU kDisp]
2019-07-15 08:24:21 -0300 Assertions            PID 844(prl_vm_app) Created NetworkClientActive "CMacPowerHelper::Do Background Tasks" 00:00:00  id:0x0x11000085df [System: DeclUser SRPrevSleep DispWake NetAcc kCPU kDisp]
2019-07-15 08:24:21 -0300 Assertions            PID 184(mDNSResponder) Released MaintenanceWake "mDNSResponder:maintenance" 00:00:00  id:0x0xd000085de [System: DeclUser SRPrevSleep DispWake NetAcc kCPU kDisp]
2019-07-15 08:24:22 -0300 Assertions            PID 59(powerd) Released InternalPreventSleep "Holding in darkwake for up to 30 seconds to update inactivity prediction" 00:00:01  id:0x0xd000085d9 [System: PrevIdle DeclUser SRPrevSleep DispWake NetAcc IPushSrvc kCPU kDisp]
2019-07-15 08:24:22 -0300 Assertions            PID 59(powerd) Created InternalPreventSleep "Assertion to change proximity monitoring state" 00:00:00  id:0x0xd000085ec [System: PrevIdle DeclUser SRPrevSleep DispWake NetAcc IPushSrvc kCPU kDisp]
2019-07-15 08:24:24 -0300 Assertions            PID 59(powerd) Released InternalPreventSleep "Assertion to change proximity monitoring state" 00:00:01  id:0x0xd000085ec [System: PrevIdle DeclUser SRPrevSleep DispWake NetAcc IPushSrvc kCPU kDisp]
2019-07-15 08:24:25 -0300 Assertions            PID 59(powerd) Created InternalPreventSleep "Assertion to change proximity monitoring state" 00:00:00  id:0x0xd000085f6 [System: PrevIdle DeclUser SRPrevSleep DispWake NetAcc IPushSrvc kCPU kDisp]
2019-07-15 08:24:25 -0300 Assertions            PID 59(powerd) Released InternalPreventSleep "Assertion to change proximity monitoring state" 00:00:00  id:0x0xd000085f6 [System: PrevIdle DeclUser SRPrevSleep DispWake NetAcc IPushSrvc kCPU kDisp]
2019-07-15 08:24:27 -0300 Assertions            PID 881(iTunes) Created NetworkClientActive "com.apple.iTunes.server" 00:00:00  id:0x0x11000085f8 [System: PrevIdle DeclUser SRPrevSleep DispWake NetAcc IPushSrvc kCPU kDisp]
2019-07-15 08:24:29 -0300 WakeTime              WakeTime: 0.194 sec

As can be seen, after 1 hour, the computer goes into standby mode, and only comes back when I open the lid.

Ongoing battery drain issues

After implementing both fixes above, although the computer is correctly going into standby mode now, there is still an issue with the battery. Note that, when the lid was closed, the computer had 26% charge:

2019-07-13 13:28:52 -0300 Sleep                 Entering Sleep state due to 'Clamshell Sleep':TCPKeepAlive=disabled Using Batt (Charge:26%) 3621 secs

After 1 hour, when going into standby mode, it had 25% charge:

2019-07-13 14:29:13 -0300 DarkWake              DarkWake from Normal Sleep [CDN] due to EC.SleepTimer/SleepTimer: Using BATT (Charge:25%) 0 secs
...
2019-07-13 14:29:13 -0300 Sleep                 Entering Sleep state due to 'Maintenance Sleep':TCPKeepAlive=disabled Using Batt (Charge:25%) 150908 secs

When the computer woke up, it thought it still had 25% charge, but this quickly adjusted to 7%, which matched the value I found in the battery menu bar icon:

2019-07-15 08:24:21 -0300 DarkWake              DarkWake from Standby [CDN] due to EC.ACAttach/HID Activity: Using BATT (Charge:25%) 0 secs 
...
2019-07-15 08:24:21 -0300 Wake                  DarkWake to FullWake from Standby [CDNVA] due to Notification: Using AC (Charge:7%)

This means the battery drained 18% in a 42 hour interval. Extrapolating this, it would mean that, had the battery started at 100%, it would have drained to 0% in about 233 hours, i.e. less than 10 days. This falls quite short of Apple's claim of "up to 30 days standby time" (see here, under "Battery and Power"). This appears to be a widespread issue, and unfortunately, keeping with Apple's standard procedure in such cases, they're pretending the problem doesn't exist.

Solution 2:

For me turning off bluetooth was the only thing that solved this. I turned it off from the menu bar and clicked "Turn Bluetooth Off". Now the battery no longer drains when I put the mac to sleep.

I had these same error messages, and previously I tried a whole bunch of things, including resetting PRAM, resetting SMC (System management controller), changing all sorts of settings on pmset, turning off power-nap, wake on bluetooth, but none of these worked. Only turning off bluetooth completely worked.