Sometimes Packet Tunnel Provider stops silently

We have a VPN app with Packet Tunnel Provider for iOS. The option disconnectOnSleep from <NetworkExtension/NEVPNProtocol.h> is false.

Sometimes our users experiences an issue when the process stops itself after some period of time without crashes.

In the logs, everything looks Ok.

The iOS versions with the reproduced issue are 16.7.2, 17.1. Memory usage of our VPN app is ~9Mb.

I've implemented NEProvider's interfaces in our subclass of NEPacketTunnelProvider:

override func sleep(completionHandler: @escaping () -> Void) {
    NSLog("Sleep")
    completionHandler()
}

override func wake() {
    NSLog("Wake")
    super.wake()
}

After retesting by users, I've noticed that there are multiple subsequent calls of sleep-wake, sleep-wake, sleep-wake API, but in the problem scenario, our logs and the process stops after "Sleep".

I've read the post https://developer.apple.com/forums/thread/95988, and didn't get an idea: what if sleep(_:) nor wake() are not implemented - how does it affect the VPN app behaviour?

Is it a correct hypothesis that sometimes the iOS kills the process silently without crash? What are the triggers that force the system to kill a VPN app?

Is it a correct hypothesis that sometimes the iOS kills the process silently without crash? What are the triggers that force the system to kill a VPN app?

Typically if the OS is reclaiming the processes memory or terminating the process then there will be an indication of this in the log or sysdiagnose. For example, a watchdog termination by your process or even one of the NE processes. Do you see any of that taking place in the log archive or sysdiagnose?

Sometimes Packet Tunnel Provider stops silently
 
 
Q