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?

Replies

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?

  • No, I don't see any errors in our extension's logs. The memory limit hasn't been reached; the extension app takes ~9MB on iOS 17.3.1.  I have collected sysdiagnose and filtered it with the NE-process name, NE-process ID, and Bundle ID. I haven't seen something odd with these filters around reproduction's timestamp. I have filled out the report FB13662005 in Feedback Assistant with sysdiagnose and NE-logs attached.

Add a Comment