Skip to content

fix: make scanning poll loop lifecycle-aware#58

Merged
chrisuthe merged 1 commit intomainfrom
fix/scanning-poll-lifecycle
Mar 8, 2026
Merged

fix: make scanning poll loop lifecycle-aware#58
chrisuthe merged 1 commit intomainfrom
fix/scanning-poll-lifecycle

Conversation

@chrisuthe
Copy link
Copy Markdown
Owner

Summary

  • Wrapped the while(true) scanning poll loop in MainActivity.kt with repeatOnLifecycle(Lifecycle.State.STARTED) so it automatically pauses when the activity is stopped and resumes when started.
  • Previously, this coroutine ran indefinitely via lifecycleScope.launch without lifecycle awareness, continuing to poll isDiscovering() even when the activity was not visible.

Test plan

  • Verify scanning state still updates correctly when on the server list screen
  • Verify the polling stops when the app is backgrounded (check via logging or debugger)
  • Verify no regressions in discovery behavior after returning to the app

Wrap the while(true)/delay(1000) scanning poll loop with
repeatOnLifecycle(Lifecycle.State.STARTED) so it automatically
suspends when the activity is stopped and resumes when started.
Previously the coroutine ran indefinitely in lifecycleScope
regardless of activity visibility.
@chrisuthe chrisuthe merged commit 4d4315d into main Mar 8, 2026
@chrisuthe chrisuthe deleted the fix/scanning-poll-lifecycle branch March 8, 2026 02:40
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