Skip to content

fix: reload the widgets when fresh readings resume - #119

Merged
henrikogaard merged 1 commit into
mainfrom
fix/widget-reload
Oct 27, 2026
Merged

henrikogaard merged 1 commit into
mainfrom
fix/widget-reload

Conversation

@henrikogaard

Copy link
Copy Markdown
Owner

Problem

On 0.6.1 the desktop widget showed "Open Tidegauge to start" for 12+ hours while the app was running and writing fresh readings every 12 s. macOS had not asked the widget for a new timeline in that time, and the widget's last timeline entry is the "not running" state.

Change

  • widgets/Center/WidgetCenter.swift: a C-callable tidegauge_reload_widgets() that calls WidgetCenter.shared.reloadAllTimelines().
  • build.rs: compiles it with xcrun swiftc into a static library and links WidgetKit and the system Swift runtime.
  • src/widget_export.rs: calls it on the first successful write after any other outcome (launch, and resuming after sleep or stale samples). A steady state does not call it again.

WidgetKit accepts the reload only from the app's main executable. A helper in Contents/MacOS got ChronoCoreErrorDomain Code=10, and the same code as the bundle's main executable worked. That is why this links Swift into the binary instead of shipping a helper.

Verification

  • cargo test --locked: 439 passed, 28 ignored.
  • Preview package with widgets, re-signed with Developer ID, run on this Mac: log shows reloadAllTimelines() - reloaded all timelines from tidegauge, then the widget extension decoded a snapshot 0.48 s old.
  • otool -L shows WidgetKit and /usr/lib/swift runtime only, so nothing new needs to be bundled.

Not checked

  • Release CI (Xcode 16.4) has not built this yet; the Swift is one call and targets macOS 11.
  • Waking from real sleep was not run end to end; it goes through the same path as launch (stale → wrote).

After launch or sleep, macOS could leave the desktop widgets on
"Open Tidegauge to start" for hours while the app kept writing fresh
readings, because nothing asked WidgetKit to rebuild their timelines.

WidgetKit accepts a reload only from the app's main executable, so a
small Swift function is compiled by build.rs and linked into the
binary. The app calls it on the first successful write after any other
outcome: at launch and when readings resume after sleep.
@henrikogaard
henrikogaard merged commit 565080a into main Oct 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant