Hey,
I am working on an NEPacketTunnelProvider https://developer.apple.com/documentation/networkextension/nepackettunnelprovider Extension and I try to understand when the stopTunnel(with:completionHandler:) function is called from the system. I am using an On Demand Profile but never see the function beeing called.
This thread describes a problem when the startTunnel Function is not returning. https://forums.developer.apple.com/message/234030#234030 I verified that my startTunnel function is returning. Nonetheless, I create an workerthread which handles the packetflow which does not return. Is this possibly a problem?
According to this document https://help.apple.com/configurator/mac/2.0/#/apd4CE9487D-EC56-4548-BE53-12639EAF8CAC , it is never called when VPN is enabled by hand in the settings, otherwise it shall stop after 2 minutes.
Is it necessary that the screen is off?
Is the timeout starting when no packets are send to the TUN device?
What are the conditions for the OS to call stopTunnel(with:completionHandler:)?