PSA: If your 2015 or 2016 MBP has some battery drain while sleeping, here is the fix

Discussion in 'MacBook Pro' started by Mixolyd, Jan 9, 2017.

  1. Mixolyd, Jan 9, 2017
    Last edited: Apr 22, 2017

    Mixolyd macrumors member

    Mixolyd

    Joined:
    Jul 10, 2014
    Location:
    Oregon
    #1
    Backstory: I just got a 2016 13'' non TB MBP. I noticed that after sleeping for a day or two, there was some battery drain. I also have a 2014 rMBP which does not drain at all. I tested and it seemed to drain 5% over 24 hours while the 2014 did not. After pulling my hair out trying to find a fix, I finally found one. Credit goes to Seny on the official Apple forums who figured it out. Link The issue seems to be that 2015 and 2016 MBPs are set to wake up during sleep for notifications. If I ran "log show --style syslog | fgrep "Wake reason" I'd have wakes every 10-20 minutes.

    To see if you are affected, run "ioreg -l | grep IOPlatformFeatureDefaults" -- On my 2014 model TCPKeepAliveDuringSleep was set to No, but on my 2016 it was set to Yes.

    In order to change this, first you have to turn off SIP. Boot into recovery mode (CMR+R) then "csrutil disable" (don't forget to enable again later). Then in Finder menu Go to folder "/System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns/X86PlatformPlugin.kext/Contents/Resources" Depending on which MBP you have, the file you have to edit is different. Run " ioreg -l | grep board-id" in terminal to figure out the correct file. Then right click on the file, get info, change permission for Everyone to read & write. Open with texteditor (I used Textwrangler) and look for these 4 entries and just completely delete them

    > <key>TCPKeepAliveDuringSleep</key>
    > <true/>
    > <key>TCPKeepAliveExpirationTimeout</key>
    > <integer>43200</integer>
    > <key>NotificationWake</key>
    > <true/>
    > <key>DNDWhileDisplaySleeps</key>
    <false/>


    Save and reboot. Worked for me. Now I have very few wakes when sleeping and battery drain is much better. I'm reporting the bug to Apple. Please do the same so they fix it. Whatever changes you make will probably be overwritten by any updates so they'll need to fix it permanently


    Update: I no longer recommend using this fix. Something changed in 10.12.4. After redoing the steps outlined, I saw that the drain was about the same as without the fix, but then for the next days saw that it actually was worse. One night my battery dropped 10% overnight, and pmset showed no wakes. Very odd. I had to revert to a Time Machine backup because simply undoing the steps by changing the text does not revert this for whatever reason. So my suggestion is that if you are on 10.12.4 then do not follow this guide and learn to live with the slight drain that occurs. I'm not aware of any fix at the moment. Note this is with a 2016 MBP nTB so it may be different with 2015 or the regular MB.
     
  2. kwandrews macrumors 6502

    Joined:
    Mar 7, 2012
    Location:
    Colorado, USA
    #2
    I'll wait for Apple to fix it, but mine was set to YES as well. Thanks for the info, at least we know if CAN be fixed ;-)
     
  3. duervo, Jan 9, 2017
    Last edited: Jan 10, 2017

    duervo macrumors 68000

    duervo

    Joined:
    Feb 5, 2011
    #3
  4. Antairez macrumors regular

    Antairez

    Joined:
    Mar 17, 2015
    #4
    Tried it, gonna report if this helps.
    May I ask why is this turned on by Apple in the first place? Must have served some purpose.
     
  5. maflynn Moderator

    maflynn

    Staff Member

    Joined:
    May 3, 2009
    Location:
    Boston
    #5
    Yes, Apple's power nap. The computer wakes up a bit every so often to check for notifications and email.

    Apple's KB articles goes into more detail: https://support.apple.com/en-us/HT204032
     
  6. jun180 macrumors regular

    jun180

    Joined:
    Apr 27, 2010
    #6
    I have been trouble shooting battery issues on the 13" TB and 15" TB models. I came to the same theory as you, that the laptops were waking while 'asleep' due to notifications from apps like imessages or facebook.

    Just wondering if in your notifications system settings -> do not disturb, you had the 'When the display is sleeping' radio button turned off? I enabled this setting so that the computer would not wake while the display is sleeping, and this significantly improved my battery life while the laptop was asleep.
     
  7. thesaint024 macrumors 65816

    thesaint024

    Joined:
    Nov 14, 2016
    Location:
    Republic of California
    #7
    Thanks for this. But I'm wondering how this is different from forcing a hibernate with the "sudo pmset" command? If you don't want the MBP waking for notifications, isn't it essentially doing the same thing as hibernating - remaining in low power with no waking or any other interruptions to a sleep/hibernate state? I'm not suggesting one is better than another, I am just not clear on the practical differences. Also, the forcing hibernate seems to be a simpler fix with a single command line. I was unsuccessful in doing this, but that's another issue.
     
  8. tivoboy macrumors 68030

    Joined:
    May 15, 2005
    #8
    mine was already set to NO, don't recall changing it.
     
  9. t2nerb macrumors newbie

    Joined:
    Feb 22, 2008
    #9
    Wow. Good stuff here, thanks a bunch!

    I am currently having a problem with my MBPTB draining ~20% overnight, so definitely poses some concern.

    Will try this solution will report back.
     
  10. Antairez, Jan 10, 2017
    Last edited: Jan 10, 2017

    Antairez macrumors regular

    Antairez

    Joined:
    Mar 17, 2015
    #10
    upload_2017-1-11_15-39-8.png
    [​IMG]
    Even when Power Nap is off in the settings, its still working?
     
  11. t2nerb macrumors newbie

    Joined:
    Feb 22, 2008
    #11
    Mixolyd,

    Did you completely remove the 'TCPKeepAliveExpirationTimeout'? I changed the other parameters, but not sure if leaving 'TCPKeepAliveExpirationTimeout' at 43200 seconds will affect it.
     
  12. WhiteWhaleHolyGrail macrumors 6502a

    WhiteWhaleHolyGrail

    Joined:
    Nov 14, 2016
    #12
    Yep - I did the same and had the same results.
     
  13. Papakaliati macrumors newbie

    Papakaliati

    Joined:
    Dec 16, 2016
    Location:
    Thessaloniki
    #13
    Intrestringly enough, on beta 4 the command
    ioreg -l | grep IOPlatformFeatureDefaults
    is not working.

    And now I see that that is it because the option to power wake up has been completely removed from the Energy Saver.
     
  14. Mixolyd, Jan 12, 2017
    Last edited: Jan 12, 2017

    Mixolyd thread starter macrumors member

    Mixolyd

    Joined:
    Jul 10, 2014
    Location:
    Oregon
    #14
    This has nothing to do with DND. DND is for when your computer is awake. The issue is that the computer was being woken up during sleep (and while on battery) to receive push notifications. DND by default turns on when the display is sleeping, and I have that enabled.

    Power nap is only when the computer is plugged in. I also tried completely disabling power nap and it made no difference.

    https://support.apple.com/en-ca/HT204353

    I think I had DND while sleep set to on. Isn't that the default setting? Was yours off by default?

    I'm curious if you run "log show --style syslog | fgrep "Wake reason"" do you see ARPT Network wakes? Those were the ones I had very often before

    You could force hibernate, and I thought of doing that, but then your mac wakes up slower. The difference is that sleep stays in RAM while hibernate stays in SSD. It's up to you whether waking up slower is bothersome. For me I prefer waking up quickly with sleep.

    I just kept TCPKeepAlive as is and didn't touch it.

    Seriously? Hmmm, have you tried the rest of the instructions? When you go to edit the file that's relevant for your computer, do you still see TCPKeepAliveDuringSleep?
    --- Post Merged, Jan 12, 2017 ---
    see this https://support.apple.com/en-ca/HT204353 It's a new 'feature'. It does say on the bottom that DND disables this. I do believe I had DND while sleeping enabled in Notifications setting, as that is the default setting. Maybe it's a bug that DND while sleeping isn't disabling the push notifications. Not sure.
     
  15. duervo macrumors 68000

    duervo

    Joined:
    Feb 5, 2011
    #15
    DND is not just for when the system is awake. DND can apply even to a Mac that is in sleep mode. Notifications can still be sent to a Mac that is asleep, such as in environments where a Bonjour proxy is running (ie: AirPort base stations or Apple TVs are on the network,) unless you turn on DND like stated at the link I provided:

    "Stop notifications during the time range you specify, when the display is sleeping, or when you’re projecting the screen."
     
  16. Mixolyd thread starter macrumors member

    Mixolyd

    Joined:
    Jul 10, 2014
    Location:
    Oregon
    #16
    DND while display is sleeping is On by default. If that's the case then this shouldn't be happening
     
  17. duervo macrumors 68000

    duervo

    Joined:
    Feb 5, 2011
    #17
    It's not on by default on my system. Granted, it's not a 2016 model, but that doesn't rule out a bug in he case of the 2016's, plus I'm running 10.12.3 beta4, so that could be part of it too.
     
  18. thesaint024 macrumors 65816

    thesaint024

    Joined:
    Nov 14, 2016
    Location:
    Republic of California
    #18
    In theory I agree, but these SSD's are supposed to be much faster now. I would guess that waking up from hibernate doesn't take very long. I don't know how I can confirm if my MBP was in hibernate vs. sleep, but when I leave it on sleep overnight, I assume it's in hibernate by then, and it always wakes up pretty fast. Just talking, I don't really have a strong preference either way, I just want it to stop draining.

    The only reason I couldn't do your method is that I can't replicate your keystrokes. "ioreg -l | grep board-id" what are those vertical lines? They are different but I only know of one vertical line option on the keyboard. Sorry if noob question.
     
  19. Mixolyd thread starter macrumors member

    Mixolyd

    Joined:
    Jul 10, 2014
    Location:
    Oregon
    #19
    I just backed up and going to reinstall OSX to confirm whether it's on by default or not. If it's as simple as turning that on then that would be much easier and preferable

    Ok I'm not just talking theory here. I did force hibernate and it was slower to wake up. I have a new 2016 MBP so definitely not a slow SSD. I don't remember how much longer it took, but you can try it yourself and see. For me it was definitely noticeable. And I doubt your MBP is in hibernate since by default it's sleep. You can google how to change it. I don't remember the command

    The vertical line is | which is when you hold shift and press the key above enter/return. You could just copy and paste the command.
     
  20. thesaint024 macrumors 65816

    thesaint024

    Joined:
    Nov 14, 2016
    Location:
    Republic of California
    #20
    Maybe I'm doing it wrong then. In recovery mode, I don't have access to safari or notepad or anything else outside of terminal and finder, right? So copy/paste is out. Also there are 2 vertical lines in your string and they appear to be different. I know the one you are talking about, but isn't that a smaller vertical line in front of this one?

    I was unsuccessful in forcing hibernate too. In terminal it said I didn't have permission or something like that. Maybe I need to do it in recovery too, maybe with csrutil disabled too. I don't know what any of this is, just trying to follow instructions. DOS commands and rebuilding RAR files seem so far away now.
     
  21. Mixolyd, Jan 12, 2017
    Last edited: Jan 12, 2017

    Mixolyd thread starter macrumors member

    Mixolyd

    Joined:
    Jul 10, 2014
    Location:
    Oregon
    #21
  22. sidewinder macrumors 68020

    sidewinder

    Joined:
    Dec 10, 2008
    Location:
    Northern California
    #22
    I tried hibernatemode 25 and it took longer for my MacBook to wake up than it would to boot. On top of that, all the external disks were ejected improperly and I had to dismiss the notifications of such.
     
  23. Mixolyd, Jan 12, 2017
    Last edited: Jan 12, 2017

    Mixolyd thread starter macrumors member

    Mixolyd

    Joined:
    Jul 10, 2014
    Location:
    Oregon
    #23
    Ok so I reinstalled OSX. DND while sleep is not On by default in Notifications settings. I was wrong about that. I switched it to On, but I'm still seeing a bunch of these ARPT Network wakes (coinciding to whenever I get a new email or some other notification), so it seems that simply switching DND while display is sleeping to On does not fix this (contrary to Apple's article on Enhanced Notifications). Maybe it's a bug. If I do "ioreg -l | grep IOPlatformFeatureDefaults" then DNDWhileDisplaySleeps is still set to No.

    So unfortunately until Apple fixes this, you have to follow the directions in the OP. Or turn on hibernation if you don't mind longer wake times.
     
  24. ice29 macrumors member

    ice29

    Joined:
    Dec 9, 2016
    Location:
    Switzerland
    #24
    Thanks for this heads-up, I had these wake problems on the 2015 13" MBP lots of times, I have strongly suspected that the TCP connection will cause this, since the machine was trying to find WiFis around when closed in my backpack - and when I disable WiFi before closing the lid, no drain happens (I scripted it to shut wifi automatically when going to sleep and then enable it again, but it was not consistent and also it took much longer to find wifi when opened). But had no idea where to look for in OSX. Will try the keepalives disabled, they could be helpful for some services like VPN (and also for the notifications if one wants them, but I definitely not) but for most people they don't make any sense to be on when on sleep.
     
  25. sojers92 macrumors newbie

    Joined:
    Dec 18, 2016
    #25
    Putting every time the Macbook in hibernation means writing 8/16gb of data (depending on your ram) on the SSD, don't know how healthy that might be. However, I just noticed that mine wakes up too when the lid is closed. From my other Macbook every hour I get a notification from Steam saying that the Macbook nTB is available for streaming, and one minute later that is not available anymore.
     

Share This Page