All four background-task methods on Android resolve successfully and do no work at all.
@JavascriptInterface
fun registerBackgroundTask(taskId: String) {
try {
// WorkManager tasks don't require explicit registration, just track them
activity.runOnUiThread {
webView.evaluateJavascript(
"window._craftBgTaskResolve && window._craftBgTaskResolve({taskId: ${jsQuote(taskId)}, registered: true})", null)
}
} catch (e: Exception) { ... }
}The comment says "just track them" and nothing is tracked — there is no field, no map, no set. registerBackgroundTask resolves {registered: true}.
scheduleBackgroundTask is explicit about it:
// Note: Full WorkManager implementation requires adding the dependency
// implementation 'androidx.work:work-runtime-ktx:2.9.0'
// This is a placeholder that shows the API structureand then resolves {taskId, scheduled: true, delay}. Nothing is enqueued, no WorkRequest is built, and the dependency is not in the generated build.gradle.kts.
cancelBackgroundTask resolves {cancelled: true} for a task that was never scheduled, and cancelAllBackgroundTasks resolves for all of them.
Why the shape is the problem
A page that schedules a nightly sync and checks the reply is told it succeeded. Nothing runs, and there is no later signal — no failure, no timeout, no event. The only way to notice is that the work never happens, which on a background task can take days to attribute.
_craftBgTaskReject is already assigned by the injected JS, so there is somewhere honest to send this.
Two ways out
- Implement it.
androidx.work:work-runtime-ktxin the app template,OneTimeWorkRequestBuilderwith theConstraintsthe API already accepts (requiresNetwork,requiresCharging,delay), andWorkManager.getInstance(activity).enqueueUniqueWork(taskId, ...).cancelUniqueWork(taskId)andcancelAllWork()then mean something, andregisterBackgroundTaskcan go — the comment is right that WorkManager needs no registration. - Reject.
"Background tasks require the WorkManager dependency", which is whatsignInWithGoogleandscanQRCodealready do for their own missing setup, and is honest today.
Either is better than the current answer. The choice is a product one — whether craft apps carry WorkManager — which is why this is an issue rather than a patch.
Not migrated to Zig
android_conformance_test.zig records all four as deliberate deferrals. Porting a method whose whole body is a fabricated success would spread the fabrication into a second language, which is the same reason setBadge (#148) and the AR trio are not migrated.
Related: #127, #148, #154, #157, #159, #169, #175 — replies that are sent but do not mean what they appear to.