The documentation explains that the NEPacketTunnelProvider's sleepWithCompletionHandler: and wake methods are called when the device is going to sleep or waking up. The expectation is that the device will enter and remain in a sleep state for some extended period of time.
On iOS 17 we're seeing the PacketTunnelProvider receive wake calls almost immediately. Is there a known issue where the PacketTunnelProvider does Not remain in a sleep state?
In our logging, we see the PacketTunnelProvider is constantly alternating between sleep/wake states.
- On iOS 16, these methods are called on an average of 42 seconds apart from each other.
- In some cases, we do see the device in a sleep state for 2 to 3 minutes.
- On iOS 17, these methods are called on an average of 6 seconds apart from each other.
- The device only sleeps for a few seconds and Not for minutes.
- This will drain the battery. Will the app be charged for battery usage if the OS decides Not to remain in sleep mode?
- Is there a bug where the an iOS 17 device running a VPN will not stay in sleep mode?
Also, we do Not modify the NEVPNProtocol's disconnectOnSleep field. ie Should be defaulting to NO
On a device running iOS 16.3.1, with the screen locked and un-plugged from a power source
- PID 4574: across 9.6 minutes (576 seconds)
- Connected to Wi-Fi.
- 10 calls (5 sleep / 5 wake)
- Avg frequency of 57.6 seconds apart.
- PID 4581: across 10.3 minutes (616 seconds)
- Wi-Fi disabled, Connected to Cellular.
- 22 calls (11 sleep / 11 wake)
- Avg frequency of 28 seconds apart.
- PID 4600: across 10.6 minutes (635 seconds)
- Connected to Wi-Fi.
- 12 calls (6 sleep / 6 wake)
- Avg frequency of 52.92 seconds apart.
(576 + 616 + 635) = 1827 seconds.
(10 + 22 + 12) = 44 calls.
1827 / 44 = 41.52 seconds.
On a device running iOS 17.0 (Build 21A5326a), connected to Wi-Fi:
- PID 14357: across 94.7 minutes (5682 seconds)
- 1034 calls (517 sleep / 517 wake)
- Avg frequency of 5.5 seconds apart.
- PID 14412: across 92.5 minutes (5547 seconds)
- 508 calls (254 sleep / 254 wake)
- Avg frequency of 10.9 seconds apart.
- PID 14721: across 92.5 minutes (5547 seconds)
- 1248 calls (624 sleep / 624 wake)
- Avg frequency of 4.4 seconds apart.
(5682 + 5547 + 5547) = 16776 seconds.
(1034 + 508 + 1248) = 2790 calls.
16776 / 2790 = 6.01 seconds.