Stop tunnel method gets interrupted on 'providerDisabled'

Hi, I have a NEPacketTunnelProvider running.

When uninstalling the app, I've noticed that the class calls stopTunnel with reason: providerDisabled. However when I want to cleanly finish up the stop the method gets cancelled before it finishes an asynchronous task. (takes maybe half a second)

Any technique how I can ensure that the work still gets done before this happens?

Post not yet marked as solved Up vote post of fuzi-ohana Down vote post of fuzi-ohana
848 views

Replies

What do you mean by “the method gets cancelled”?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@eskimo, Here is a pseudo code scenario, with logging when the extension gets called stopTunnel with a reason being .providerDisabled. I have a OSLog instance to check how far it will execute the method. It will only print "stopTunnel because" and the "starting clean-up") and then gets exited due to uninstall I guess.

override func stopTunnel(with reason: NEProviderStopReason) async {
    logger.log("Stop tunnel because: \(reason, privacy: .public)")

    if case .providerDisabled = reason {
        logger.log("Starting clean-up")
        let result = await doPseudoCodeCleanup()

        switch result {
            case .success:
                logger.log("clean up done")

            case .failure(let error):
                logger.log("Clean up failed due to error: \(error.localizedDescription, privacy: .public)")
        }

        logger.log("providerDisabled cleanup, done.")
    }

    logger.log("Stop tunnel end")
}

Here is a pseudo code scenario

Thanks. That clarifies things.

What platform is this on?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I observe this on iPad OS 16 (last beta before RC) and iOS 16 (RC).

Same issue any updates?

@eskimo to track it FB11875881

Thanks in advance.

Add a Comment