fix(playback): persist offline playback position across sessions - #623
Merged
RadicalMuffinMan merged 1 commit intoJun 23, 2026
Merged
RadicalMuffinMan merged 1 commit into
RadicalMuffinMan merged 1 commit into
Conversation
Root cause: OfflinePlaybackTracker.startTracking() called the async stopTracking() without await. The deferred cleanup nullified _activeItemId after the new session had already set it, causing every periodic save and the final exit save to silently no-op. Changes: - Make startTracking() async and await stopTracking() so the previous session's DB write completes before the new session begins. - Snapshot the manager position in stopTracking() before cancelling the stream subscription to capture the freshest position. - Read the start position from the DB (via OfflineRepository.getItem) instead of the potentially stale DownloadedItem passed from the UI. - Await PlaybackManager.pendingStop before the DB read so any in-flight stop from the unawaited exit flow has committed. - Expose PlaybackManager.pendingStop getter for the above. - Trigger offline-to-server progress sync when connectivity is restored. Closes Moonfin-Client#376
8 of 9 tasks
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.
Pull Request
Summary
Fix offline playback progress not being persisted across sessions. After seeking to a position and exiting playback, re-entering the same item would always restart from 0:00 instead of resuming from the saved position.
Related Issues
Link related issues or tickets separated by commas.
Type of Change
Changes Made
List the key changes included in this PR.
OfflinePlaybackTracker.startTracking() called the async stopTracking() without await. The deferred cleanup set _activeItemId = null after the new session had already assigned its item ID, causing every subsequent periodic save and the final exit save to silently return (because _activeItemId was null). Fixes applied across 5 files:
Platform
Testing
Describe how this change was tested.
Test Steps
Screenshots (if applicable)
A tale in 6 images...
Checklist