Skip to content

Optimize power usage by gating UI work and polling on interactivity#1945

Merged
theovilardo merged 1 commit into
masterfrom
optim/wear-os-general-optimizations
May 9, 2026
Merged

Optimize power usage by gating UI work and polling on interactivity#1945
theovilardo merged 1 commit into
masterfrom
optim/wear-os-general-optimizations

Conversation

@theovilardo
Copy link
Copy Markdown
Owner

  • Introduce WearLifecycleState to track whether the app is in the foreground and the device is in an active (non-ambient) state.
  • Update WearMainActivity to monitor ambient mode transitions using AmbientLifecycleObserver.
  • Gate continuous animations, such as the EQ icon and play-button rotation, on the interactive state to save battery.
  • Optimize polling loops in VolumeScreen, OutputScreen, and WearPlayerViewModel by increasing delays and pausing work when the screen is off or in ambient mode.
  • Improve PlayerScreen performance by memoizing background brushes to reduce GC churn and aligning clock updates to minute boundaries.
  • Gate player position updates in WearLocalPlayerRepository to avoid unnecessary StateFlow churn when the UI is not visible.

- Introduce `WearLifecycleState` to track whether the app is in the foreground and the device is in an active (non-ambient) state.
- Update `WearMainActivity` to monitor ambient mode transitions using `AmbientLifecycleObserver`.
- Gate continuous animations, such as the EQ icon and play-button rotation, on the interactive state to save battery.
- Optimize polling loops in `VolumeScreen`, `OutputScreen`, and `WearPlayerViewModel` by increasing delays and pausing work when the screen is off or in ambient mode.
- Improve `PlayerScreen` performance by memoizing background brushes to reduce GC churn and aligning clock updates to minute boundaries.
- Gate player position updates in `WearLocalPlayerRepository` to avoid unnecessary `StateFlow` churn when the UI is not visible.
@theovilardo theovilardo merged commit 9995a88 into master May 9, 2026
4 checks 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