Skip to content

Go idle while a phone app is in the background - #35

Merged
masonasons merged 1 commit into
masonasons:mainfrom
aaron-gh:pr/idle-in-background
Nov 11, 2026
Merged

masonasons merged 1 commit into
masonasons:mainfrom
aaron-gh:pr/idle-in-background

Conversation

@aaron-gh

@aaron-gh aaron-gh commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

An open audio output holds the audio wakelock even when silent. With the phone
kept awake, the live streams and the auto-refresh timer kept the radio and CPU
busy for a screen nobody was looking at.

Core (CoreSession):

  • pause publishes positions as before, then closes the audio output
    (sound_.suspend()), stops every stream and sets backgrounded_.
  • While backgrounded, update_streaming opens nothing and the auto-refresh loop
    skips its ticks.
  • resume reopens audio, reconnects streams and refreshes the current timeline,
    plus the account's other open timelines. Other accounts catch up on the next
    auto-refresh. Push notifications cover new activity meanwhile.

Android:

  • A configuration change (folding or unfolding) is not treated as leaving the
    app, so it no longer stops and restarts sounds and streams.
  • The paused flag is per process, so a window rebuilt while paused still sends
    resume.

iOS already sends pause / resume; no iOS change. Windows, macOS and Linux
don't send pause, so they are unaffected.

Testing: Android tested on a Galaxy Z Fold 7. iOS not tested. Core syntax-checked
with clang on macOS; not built on Windows, unit tests not run.

pause now closes the audio output, stops the live streams and holds the auto-refresh timer until resume. An open audio output holds the audio wakelock even when silent, and with the phone kept awake the streams and timer kept the radio and CPU busy for a screen nobody was looking at. resume reopens audio, reconnects the streams and refreshes the account's open timelines (the current one first; other accounts on the next auto-refresh). Push notifications cover new activity meanwhile.

Android and iOS both send pause/resume already. On Android, a configuration change (folding or unfolding) is not treated as leaving the app, and the paused flag is per process so a window rebuilt while paused still resumes.

Core syntax-checked with clang on macOS; Android compiles. Not built on Windows or run on iOS here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aaron-gh
aaron-gh marked this pull request as ready for review November 11, 2026 10:55
@masonasons
masonasons merged commit 3a2fae0 into masonasons:main Nov 11, 2026
5 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.

2 participants