Last active
January 28, 2026 17:09
-
-
Save jubishop/cf4a26b291e67e195cf29d25f9795026 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| Analysis Summary | |
| Based on the logs and code review, I found a reproducible edge case related to the AirPods sleep detection feature. | |
| What Happened (Timeline) | |
| ┌─────────────────────┬────────────────────────────────────────────────────────────────┐ | |
| │ Time (UTC) │ Event │ | |
| ├─────────────────────┼────────────────────────────────────────────────────────────────┤ | |
| │ 2026-01-26 20:45:53 │ App launched, seeking to position 27:29 │ | |
| ├─────────────────────┼────────────────────────────────────────────────────────────────┤ | |
| │ 2026-01-26 20:45:53 │ Playback started │ | |
| ├─────────────────────┼────────────────────────────────────────────────────────────────┤ | |
| │ 2026-01-26 21:02:29 │ Audio interruption (pause) - AirPods sleep detection triggered │ | |
| ├─────────────────────┼────────────────────────────────────────────────────────────────┤ | |
| │ 2026-01-26 21:04:38 │ Audio interruption ended without .shouldResume flag │ | |
| ├─────────────────────┼────────────────────────────────────────────────────────────────┤ | |
| │ 2026-01-27 00:52:43 │ App relaunched, seeking to position 42:41 │ | |
| └─────────────────────┴────────────────────────────────────────────────────────────────┘ | |
| The user listened for ~17 minutes (from 27:29 to approximately 44:29), but when they resumed, the position was 42:41 - about 1.5-2 minutes earlier than where | |
| they actually were. | |
| Root Cause | |
| The pause() function does not explicitly save the current playback position. | |
| Looking at PodAVPlayer.swift:170-173: | |
| func pause() { | |
| Self.log.debug("pause: executing") | |
| avPlayer.pause() // No position save! | |
| } | |
| Position is only saved: | |
| 1. Every 3 seconds during active playback via the periodic time observer | |
| 2. On explicit seek operations | |
| When the AirPods sleep detection pauses playback: | |
| 1. The audio interruption triggers pause() | |
| 2. The periodic time observer may have saved position up to 3 seconds ago | |
| 3. The position at the exact moment of pause is not saved | |
| Why the "5-10 minutes" perception? | |
| The user mentioned "5 or 10 minutes earlier." The logs show a smaller gap (~2 minutes), but: | |
| - Perception while falling asleep can be fuzzy | |
| - The periodic time observer might have stopped saving earlier if the app was backgrounded | |
| - If listening at a faster playback rate (e.g., 1.5x), the real-time gap would feel longer | |
| Actionable Fix | |
| Save position immediately on pause, especially during audio interruptions: | |
| func pause() async { | |
| Self.log.debug("pause: executing") | |
| avPlayer.pause() | |
| try? await saveCurrentTime(avPlayer.currentTime()) // Add this | |
| } | |
| Or specifically in the audio interruption handler in PlayManager.swift:591-592: | |
| case .pause: | |
| // Save position before pausing | |
| try? await podAVPlayer.saveCurrentTimeNow() | |
| await pause() | |
| Secondary Finding | |
| The warning at AudioInterruption.swift:28 indicates Apple's AirPods sleep detection ends the interruption without the .shouldResume flag, which is expected | |
| behavior - but worth noting for any future resume-on-wake feature. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment