Dear Apple Support Team,
My app, io.cylonix.sase, has a BGAppRefreshTask (io.cylonix.sase.ios.refresh) that is canceled by dasd ~9ms after submission from a Network Extension. Please help identify the cause and suggest a solution.
App Details:
App ID: io.cylonix.sase iOS Version: 17.1.1 (iPhone Xs Max) Network Extension: saseWgNetworkExtension with packet-tunnel-provider entitlement Use Case: VPN app; Network Extension records file receipts in shared group UserDefaults and schedules BGAppRefreshTask to wake the main app. App Usage: High (frequently used) System State: Sufficient resources (not low on battery or memory) Issue: The task is submitted but canceled immediately with priority 10. It has never run, so rate-limiting is not an issue. `
debug 22:09:37.952749-0700 dasd Best binding found for evaluator 0x16d541720: <private>
debug 22:09:37.954483-0700 dasd Invoking selector backgroundTaskSchedulerPermittedIdentifiersWithContext:tableID:unitID:unitBytes: on <LSApplicationRecord 0x724844650>
default 22:09:37.955563-0700 dasd CANCELED: bgRefresh-io.cylonix.sase.ios.refresh:ABDAFA at priority 10 <private>!
Thank you for the reply and the link for detailed background task information.
Here is what I am trying to do:
So, focusing on the background approach you've been trying:
-
The system was really only designed to support task being submitted by the component that will run them, which can only be your main app.
-
To the extent that it does "work", that support is basically accidental and could break at any time.
-
Even if it did work PERFECTLY, I don't think BGAppRefreshTask would actually be a good fit for what you're trying to do.
Focussing in #3, the problem is the possible time gap between these two steps:
The network extension then needs to notify the suspended main APP about receiving the file by submitting a background task request for an ID to get the main APP to run a background task.
The main APP registers to be waken up by the ID and moves the file from the shared container to its own document area so that the Files app can view it.
Basically, the EXPECTED time gap between the submission of the task and the app being woken runs from:
-
Best case: "A several times an hour" or a delay of say 5-20 min., for an app the user uses heavily during the time window the task want to run.
-
Worse case: "Never", for an app the user rarely/never interacts with during the task time window.
Also, as I described here, the way that development device usage patterns interact with the scheduling engine mean that it's very easy to end up with a test device that makes this system look FAR more reliable/consistent that it will be in real world use. The bottom line here is that this simply is not an issue BGAppRefreshTask was ever designed to solve.
SO, in terms of what will work, I don't think there is anyway to share you group directory into Files.app (which is what you really want), but I'm double checking on that.
It's more work but the most "complete" solution would be to use a FileProvider extension, probably the replicated variant. Note that if you want to support bidirectional transfers (moving data "back" to the remote device), then EXACTLY the approach you should use.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware