🐛 Fix background audio dying after iOS audio interruptions#27
🐛 Fix background audio dying after iOS audio interruptions#27williamchong wants to merge 1 commit intolikecoin:mainfrom
Conversation
Increase auto-resume retry window from ~3s (3×1s) to ~2min (60×2s) so playback survives longer OS interruptions like Timer alerts.
There was a problem hiding this comment.
Pull request overview
Extends the iOS native audio bridge’s auto-resume behavior so playback is more likely to recover after longer OS-level audio interruptions (e.g., Timer alerts), improving background playback reliability.
Changes:
- Increase
MAX_AUTO_RESUME_RETRIESfrom 3 to 60. - Increase the auto-resume retry delay from 1s to 2s (extending the overall retry window to ~2 minutes).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| getActivePlayer()?.play(); | ||
| } | ||
| }, 1000); | ||
| }, 2000); |
There was a problem hiding this comment.
The retry delay is a raw 2000ms literal here. Since this value and MAX_AUTO_RESUME_RETRIES effectively define a single “auto-resume window”, consider hoisting the delay into a named *_MS constant near the other recovery constants to keep tuning centralized and self-documenting.
|
|
||
| // Auto-resume & stuck detection state | ||
| const MAX_AUTO_RESUME_RETRIES = 3; | ||
| const MAX_AUTO_RESUME_RETRIES = 60; |
There was a problem hiding this comment.
MAX_AUTO_RESUME_RETRIES is now coupled to the retry delay (currently 2000ms below), but the relationship isn’t encoded anywhere. Consider introducing an AUTO_RESUME_RETRY_DELAY_MS constant and deriving the max retries from a single “total retry window” duration so future changes don’t accidentally skew the intended ~2min window.
| const MAX_AUTO_RESUME_RETRIES = 60; | |
| const AUTO_RESUME_RETRY_DELAY_MS = 2000; | |
| const AUTO_RESUME_TOTAL_WINDOW_MS = 2 * 60 * 1000; // ~2 minutes | |
| const MAX_AUTO_RESUME_RETRIES = Math.floor( | |
| AUTO_RESUME_TOTAL_WINDOW_MS / AUTO_RESUME_RETRY_DELAY_MS, | |
| ); |
Increase auto-resume retry window from ~3s (3×1s) to ~2min (60×2s) so playback survives longer OS interruptions like Timer alerts.