Contribute
Register

[SOLVED] Ventura/Sonoma - Random (Scheduled PM) Wake from Sleep

Looks like it’s being scheduled for certain times as well — my pc just woke up exactly at 00:00:00 UTC, midnight for me. I hope this helps somehow
 
@jaymonkey

i updated my feedback report at apple with the new investigations. I guess it won't help, as they haven't answered my last feedbacks for over 2 years but it's worth a try.
My USB peripherals turned on every hour is really unbearable :(
 
@Lensjocky,

I've got a test install of Sonoma installed and can confirm that the wake during sleep problem is back.
Having done a few days of investigations it looks like Apple have introduced something new but i would like you to confirm my findings.

Could you please try an overnight sleep test and then in the morning use the following terminal command.
Jay,



Here's my output from last nights "sleep" attempt.
It would appear "CSPNEvaluation" is my culprit as well...

johnromeo@iHack ~ % pmset -g log | grep "Wake Request"
2023-11-08 08:07:52 -0500 Wake Requests [*process=powerd request=CSPNEvaluation deltaSecs=7228 wakeAt=2023-11-08 10:08:20]
2023-11-08 17:22:43 -0500 Wake Requests [*process=powerd request=CSPNEvaluation deltaSecs=7228 wakeAt=2023-11-08 19:23:11]
2023-11-08 21:50:55 -0500 Wake Requests [*process=powerd request=CSPNEvaluation deltaSecs=7214 wakeAt=2023-11-08 23:51:09]
2023-11-09 02:45:21 -0500 Wake Requests [*process=powerd request=CSPNEvaluation deltaSecs=7214 wakeAt=2023-11-09 04:45:35]
2023-11-09 08:14:28 -0500 Wake Requests [*process=powerd request=CSPNEvaluation deltaSecs=7228 wakeAt=2023-11-09 10:14:56]
2023-11-09 16:50:41 -0500 Wake Requests [*process=powerd request=CSPNEvaluation deltaSecs=7228 wakeAt=2023-11-09 18:51:09]
2023-11-09 21:49:30 -0500 Wake Requests [*process=powerd request=CSPNEvaluation deltaSecs=7214 wakeAt=2023-11-09 23:49:44]
2023-11-10 08:08:56 -0500 Wake Requests [*process=powerd request=CSPNEvaluation deltaSecs=7214 wakeAt=2023-11-10 10:09:10]
2023-11-12 13:38:48 -0500 Wake Requests [*process=powerd request=CSPNEvaluation deltaSecs=7228 wakeAt=2023-11-12 15:39:16]
2023-11-13 10:50:46 -0500 Wake Requests [*process=powerd request=CSPNEvaluation deltaSecs=7228 wakeAt=2023-11-13 12:51:14]
2023-11-13 22:27:09 -0500 Wake Requests [*process=powerd request=CSPNEvaluation deltaSecs=7214 wakeAt=2023-11-14 00:27:23]
johnromeo@iHack ~ %

Let me know if you need anything else.
 
Last edited:
@jaymonkey

i guess we need to dig in to powerd as it seems to schedule these new wakes besides/outside of the schedule system which is controllable via pmset (e.g. pmset repeat cancel) ... Maybe some powerd plist setting which we can influence?

These CSPNEvaluation wakes seem to be created/called directly from within some area of the kernel as i've been unable to find any file/plist that is responsible for scheduling them (at least so far).

I was able to stop the CSPNEvaluation wakes by pausing the powerd process before putting the system to sleep, however it's not a viable solution as the powerd process is also responsible for waking the system ... meaning the only way to wake the system with powerd on pause is a hard reset.

I appreciate all the feedback from everyone so far ... i'll keep digging.

Cheers
Jay
 
Last edited:
Hi Guys,

I disassembled the powerd process and it appears that CSPN refers to :-

CoreSmartPowerNap Service ...

Screenshot 2023-11-15 at 15.48.26.png
Screenshot 2023-11-15 at 15.44.36.png
This is progress as it now gives us a confirmed and understandable wake reason.

However this does make me wonder if its a bug / undocumented feature in Sonoma as one would have thought that disabling PowerNap either by System Settings or pmset terminal command should stop all PowerNap functions ?

On the other hand I feel that this is a deliberate move by Apple, every recent new version of MacOS has introduced some sort of new feature that wakes MacOS while sleeping ... we all know that Apple Silicon Macs are very energy efficient but FFS, its like playing whak-a-mole, when are Apple going to acknowledge that sleep MEANS SLEEP !!

I'll keep digging :banghead:

Cheers
Jay
 
Last edited:
@jaymonkey

nice find. So sonoma disregards disabled powernap. I think it's as a bug, who tells Apple when Apple disregards Feedback?
 
Last edited:
@jaymonkey Hi again, take a look at what I found in Binary Ninja. Seems like it's calling __os_feature_enabled_impl, which after googling revealed that there are feature flags inside macOS at path /System/Library/FeatureFlags/.
Screenshot 2023-11-15 at 21.10.43.png

Screenshot 2023-11-15 at 21.27.15.png

And there is powerd.plist. But we cannot edit it obviously (stored in /System)
Screenshot 2023-11-15 at 21.28.12.png

So after more googling I think you can set flags inside /Library/Preferences/FeatureFlags/Domain/ as well, I created the directory recursively using sudo mkdir -p /Library/Preferences/FeatureFlags/Domain/:
Screenshot 2023-11-15 at 21.30.13.png

Then changed the flag using nano running as superuser (sudo nano /Library/Preferences/FeatureFlags/Domain/powerd.plist)
Screenshot 2023-11-15 at 21.29.58.png

let's hope this works :headbang:
 
@sourcelocation

this really looks promising regarding CSPNEvaluation. I will give it a try!
 
Having found that the new Sonoma wake reasons where due to CSPNEvaluation (see post #52) and that the term CSPN is an abbreviation of CoreSmartPowerNap] by de-compiling the powed process (see post #65), I used grep to perform a recursive text search of /System/Library for any files that had the term CoreSmartPowerNap in them in the hope that there might be some sort of plist that would allow us to configure the feature :-

PHP:
jay@WK-2-MACOS ~ % cd /system/libaray
jay@WK-2-MACOS library % grep  -RnslI 'CoreSmartPowerNap'
FeatureFlags/Domain/powerd.plist

The search took awhile to complete but it came back with just the one hit (/System/Library/FeatureFlags/Domain/powerd.plist).

Looking at the of contents of /System/Library/FeatureFlags/Domain/powerd.plist we can see that there is a <key> named CoreSmartPowerNap which has a boolean Enabled flag set to true :-

PHP:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CoreSmartPowerNap</key>
    <dict>
        <key>Enabled</key>
        <true/>
    </dict>
</dict>
</plist>

We cant change this plist directly because the file is in the protected secure system enclave but we can override any system defined MacOS Feature Flags by creating a copy of the appropriate plist in /Library/Preferences/FeatureFlags/Domain/.

i created the folder and an edited version of the powerd.plist with the Enabled flag set to false and rebooted. i then put the system to sleep at midnight and let it sleep until midday the following day and there were no wakes at all during that 12 hour period. I'll continue to test for anther few days before calling this a conclusive fix but it's looking good.

If anyone wants to try/test it for themselves :-

1. Open Terminal
2. Create the override folder structure using the command : sudo mkdir -p /Library/Preferences/FeatureFlags/Domain/
3. Don't worry if the above command comes back with an error, it just means the folder already exists.
4. Download and unzip the attached file (modified powerd.plist.zip)
5. Using Finder, copy powerd.plist into the (new) folder: /Library/Preferences/FeatureFlags/Domain/
6. Reboot

I recommend using the above Sonoma Fix in-conjunction with my Ventura sleep fix :-


[Update] I've run the system with the above Sonoma fix for over two weeks now and have not seen any wakes.

Cheers
Jay
 

Attachments

  • powerd.plist.zip
    773 bytes · Views: 205
Last edited:
Back
Top