Hi,
Following @DTS Engineer advice, we’ve updated our implementation to stop using AppKit for handling system sleep and wake events, since our service now runs as a launchd daemon (not a LaunchAgent), as outlined in TN2083.
We've replaced the NSWorkspaceWillSleepNotification / NSWorkspaceDidWakeNotification logic with the correct IOKit-based approach using IORegisterForSystemPower.
Our daemon now listens for the following messages via a power management callback:
kIOMessageCanSystemSleep – we acknowledge this using IOAllowPowerChange()
kIOMessageSystemWillSleep – we enter suspend mode and allow the system to sleep
kIOMessageSystemWillNotSleep – we log this for visibility
kIOMessageSystemWillPowerOn and kIOMessageSystemHasPoweredOn – we resume internal state on wake
However, it looks like, despite moving to daemon domain framework, the problem persists and the system is still prevented from from remaining in deep sleep for the entire sleep duration and it resulted in battery excessive drain.
As mentioned, our product, which manages system and network extensions, was modified from an agent-based process running in the user domain to a daemon-based process running in the root domain. Below is the relevant configuration from its launchDaemon plist. Do you see anything here that could potentially cause the deep sleep prevention issue ?
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>EnablePressuredExit</key>
<false/>
<key>POSIXSpawnType</key>
<string>Adaptive</string>
<key>ProcessType</key>
<string>Interactive</string>
Thanks
Topic:
App & System Services
SubTopic:
Core OS
Tags: