iOS master dispatcher architecture concerns #78
Replies: 2 comments
|
Thanks for the detailed write-up — you've read the code correctly, and this is a real trade-off worth explaining explicitly (it isn't documented today, which is on us). What's happening today, confirmed in code:
Answering your two questions directly:
So: not a bug, but a genuine documentation gap plus a worthwhile enhancement. Filed the enhancement as #79; will also update |
|
Follow-up / correction on my reply above, after actually implementing this: 1. I was wrong about the queue. I said 2. The fix that shipped is narrower than my first draft, and specifically does not switch the dispatcher to
What did ship: The Full writeup: docs/ios-dynamic-task-scheduling.md § 5. |
Uh oh!
There was an error while loading. Please reload this page.
Hi, I have a question/concern about the iOS dynamic task / master dispatcher architecture.
I understand why the master dispatcher exists: iOS requires task identifiers to be declared in
Info.plist, so KMP WorkManager queues arbitrary dynamic task IDs internally and useskmp_master_dispatcher_taskto execute them.However, it seems that this has an important consequence on iOS:
isHeavyTask = falsewould normally be scheduled as aBGAppRefreshTaskRequest.BGProcessingTaskRequest, regardless of the characteristics of the queued tasks.requiresNetworkConnectivity = false.BGProcessingTask.This means a lightweight network task can consume a
BGProcessingTaskexecution window while offline, fail its network requirement at the worker level, and then be rescheduled again. SinceBGProcessingTaskis intended for heavier/background processing and its execution is entirely controlled by iOS, I'm concerned that this architecture could result in less favorable scheduling than simply usingBGAppRefreshTaskfor lightweight work.I understand that
BGAppRefreshTaskRequestitself has norequiresNetworkConnectivityproperty, so I'm not expecting that constraint to be represented at the Apple request level. My concern is specifically about the master dispatcher always becoming aBGProcessingTaskand always being unconstrained, even when all queued work is lightweight and/or network-dependent.Is this behavior intentional and considered the recommended iOS architecture?
If so, is the recommendation actually to use dedicated task IDs declared in
BGTaskSchedulerPermittedIdentifiersfor lightweight tasks, so that they can be scheduled directly asBGAppRefreshTaskRequests?Alternatively, would it make sense for the master dispatcher to derive aggregate constraints from the pending queue — for example, requiring network when all pending tasks require network — and potentially use
BGAppRefreshTaskwhen all pending tasks are lightweight?I'm mainly trying to understand whether this is an intentional trade-off of the dynamic-task architecture, a limitation that should be documented, or potentially an implementation issue.
All reactions