fix: prevent audible audio interruption during Turbolinks navigation (issues #8, #12)#14
Merged
Merged
Conversation
…(issues #8, #12) Root cause analysis (#8): When Turbolinks navigates, the footer's <audio> element survives as a data-turbolinks-permanent element and keeps playing. However, _applyPositionAndResume() would unconditionally seek (this._audio.currentTime = targetTime) on reconnect. This forces the browser to seek the audio buffer, creating an audible gap/stutter. Two changes to fix the interruption: 1. Threshold guard on seek: Only seek if the computed targetTime differs from the current audio time by > 0.5s. Since the audio keeps playing during navigation, currentTime is already within a few hundred ms of the correct position — no need to seek. 2. Guard play() call: Only call audio.play() if the audio is actually paused. During Turbolinks navigation, the footer never pauses the audio (disconnectedCallback explicitly avoids it), so calling play() on an already-playing element is redundant and can cause an audible glitch on some browsers. Persistence review (#12): - sessionStorage as vanilla fallback is sound: footer uses a fixed key, inline players use per-instance keys derived from src - DOM framework markers (data-turbolinks-permanent, etc.) are correctly applied in _persistenceSetup() with idempotency guard - Inline player disconnectedCallback marks paused=true on save to prevent footer audio theft on return navigation - Footer disconnectedCallback correctly avoids pausing/clearing the audio, allowing uninterrupted playback through navigation - No structural issues found; the unnecessary seek was the only behavior causing perceptible problems
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8, Closes #12
Issue #8 — Audio Interruption
Root cause: During Turbolinks navigation, the footer's permanent
<audio>element survives and keeps playing. But_applyPositionAndResume()would unconditionally seek (this._audio.currentTime = targetTime) on reconnect, forcing the browser to seek the audio buffer — creating an audible gap/stutter.Fix: Two changes in
PodcastFooter._applyPositionAndResume():Threshold guard on seek — only seek if the computed
targetTimediffers from current audio time by > 0.5s. Since the audio keeps playing during navigation,currentTimeis already within a few hundred ms of the correct position.Guard
play()call — only callaudio.play()if the audio is actually paused. The footer never pauses indisconnectedCallback, so callingplay()on an already-playing element is redundant and can cause a glitch.Issue #12 — Persistence Review
Reviewed the full persistence layer (both
<podcast-player>inline players and<podcast-footer>):sessionStoragefallback is sound — footer uses fixed key, inline uses per-instance keys derived fromsrc_persistenceSetup()with idempotency guarddisconnectedCallbackmarkspaused=trueto prevent footer audio theft on returndisconnectedCallbackcorrectly avoids pausing/clearing audio — enabling uninterrupted playback through navigationTests