pub fn start_tray_host_poll(app: AppHandle<Wry>)Expand description
Background thread that polls audio-engine playback_status and pushes fresh elapsed / total /
paused state to the tray icon and the tray-popover WebView, regardless of JS timer
throttling. The JS side (update_tray_now_playing in audio.js) still owns the title and
subtitle — those come from DOM state that Rust cannot see — but this thread keeps the
elapsed / total / playing fields live when the main window is unfocused (on macOS the rAF
loop and setInterval both pause behind isUiIdleHeavyCpu, leaving the tray frozen).
The thread is idempotent (guarded by TRAY_POLL_ACTIVE) and runs for the lifetime of the
app. On each tick:
- Poll
playback_statusfrom audio-engine. - If
loaded != true, skip (HTML5 / reverse playback does not reach the engine poll; the JStimeupdate+ keepalive paths handle those). - Merge fresh position / duration / paused into the last JS-reported
TrayPopoverEmit. - Update
tray.set_title(macOS) +tray.set_tooltipand emittray-popover-state.