You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/blog/2026-02-17-wear-os-tauri.md
+10-14Lines changed: 10 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -253,10 +253,12 @@ private fun handleOfflineSyncRequest() {
253
253
}
254
254
```
255
255
256
-
**Tier 3 — Offline writes:** When the watch sends a save or delete command and the plugin isn't loaded, a foreground service boots the Tauri runtime headlessly, waits for the plugin to initialize (~1 second), then replays the message through the normal path:
256
+
**Tier 3 — Offline writes:** When the watch sends a save or delete command and the plugin isn't loaded, the message is first persisted to `WearSyncQueue`, then a foreground service boots the Tauri runtime headlessly. After the Kotlin `Channel` is registered and the app crate explicitly signals listener readiness, queued messages are drained and forwarded:
// 1) setWatchMessageHandler registered the Channel
272
+
// 2) markWatchPipelineReady signalled Rust listeners are bound
273
+
// Then queued messages are delivered via channel.send(...)
278
274
}
279
275
}
280
276
```
281
277
282
-
This pattern — a foreground service that headlessly boots the Tauri runtime — is reusable for any Tauri Android app that needs to process background events. The key insight is that Tauri's runtime initializes quickly (~1 second on modern devices) and the static plugin reference pattern (`companion object { var instance }`) provides a clean way to detect when it's ready.
278
+
This pattern — queue first, then foreground-service boot with an explicit readiness handshake — avoids early-replay races during cold start and is reusable for any Tauri Android app that needs reliable background write handling.
283
279
284
280
## The Watch App: Compose for Wear OS
285
281
@@ -362,7 +358,7 @@ The `pathPrefix` filter ensures only messages intended for this app are delivere
362
358
363
359
**Debounce before syncing.** Without the 500ms batch collector, toggling a few alarms in quick succession would fire multiple Bluetooth round-trips. The debounce window is invisible to the user but dramatically reduces unnecessary Data Layer traffic.
364
360
365
-
**Foreground services can boot Tauri headlessly.**When you need to process a background event that requires Rust logic, launching the main activity with `FLAG_ACTIVITY_NO_ANIMATION` and polling for plugin readiness is a reliable pattern. The ~1 second boot time is acceptable for background operations.
361
+
**Foreground services can boot Tauri headlessly.**For background writes that need Rust logic, queue first, then boot in a foreground service and drain only after explicit pipeline readiness. The ~1 second runtime boot plus queue replay remains acceptable for background operations.
0 commit comments