So, let me start by jumping to the immediate point here:
This initial sync is rare from a user perspective. Some may never have initial syncs that will take 2-3 minutes.
Question is: 2-3 minutes outside the use case for this new feature?
No, not at all. We can't guarantee any specific time, but there isn't any artificial throttle on timing and, theoretically, a task could run for an hour+ under the right circumstances. On an idle device as you're describing, 2-3 min. should have been fine.
The next step here is to figure out what duet logged when we expired the task.
Huh. How long does it take to expire once you enter the background? What does the > console log show (particularly from "duet") when your task is expired?
It can be a few minutes. I haven't timed it.
OK. So the key here is that it's long enough that the processing task is keeping your app alive, at least some of the time.
As background context, what's the work you're actually "doing"?
I'm curious to why this would make a difference. It is running a long initial sync of data loading data into CoreData from a server. It almost always dies when trying to load relationships into CoreData. We are talking about 7000 plus relationship connections.
The specifics on their own don't matter, but the larger context often helps catch issues that would otherwise be missed.
Case in point:
How fast is that progress in real-world terms?
A minute or two.
How long does it take to process "one" item?
A fraction of a second, I don't have exact times.
How often are you updating progress?
Many times a second.
All other issues aside, this is something you need to take a closer look at. One of the common traps that is easy to accidentally fall into is updating progress on "computer time" not "real world time". The back of the envelope math here is:
7000 ("event count")/ 120s (2 minutes) = 58 updates/sec.
That's FAR faster than it needs to be. This might seem irrelevant, but every progress update involves a certain amount of locking (to protect the values), inter-thread communication (shifting the data to the "working" thread), and IPC (to update the visible interface). That can VERY easily steal a LOT more performance than you'd realize.
My general rule of thumb here is to update progress 2-10x/sec., assuming "meaningful" progress occurs over that time span. That's generally a good balance between looking smooth and not throwing away cycles.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware