You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Finalize the current episode's playback state before navigating to the next episode.
The existing Next Episode flow can replace the current Player destination before its asynchronous saveProgress() work finishes, which may cancel the watched/scrobble update with the old PlayerViewModel.
Changes
add saveProgressAndWait() to wait for the final playback save;
route Next Episode transitions through a single helper;
wait for persistence before calling onPlayNext();
cover the Up Next prompt, MediaNext, and the explicit Next Episode button;
Thank you for working on this. It addresses a real issue, and routing all Next Episode actions through one finalization path is the right direction.
I cannot merge it yet because a few lifecycle races remain:
saveProgressAndWait() first cancels the active save. If that save already set hasMarkedWatched = true but is cancelled before the Trakt/history work finishes, the replacement save skips the watched block and the episode can still remain unwatched.
The completion callback from an older cancelled job always clears progressSaveJob. It can therefore clear the reference to the newer save before saveProgressAndWait() joins it, allowing navigation to happen early.
After the explicit save completes, Player disposal calls saveProgress() again. Because ExoPlayer may still report isPlaying=true, this can send a new scrobble-start for the old episode after it was already paused or stopped.
Please make saveProgress() return the exact new Job and join that Job directly, only clear progressSaveJob when it still references the completing Job, and prevent the disposal save from restarting/saving the old session during a successful Next Episode transition. A focused test covering an in-flight threshold save followed by Next Episode would also be valuable.
The PR otherwise merges cleanly into current main. GitHub CI passes, both Play and Sideload compile locally, all Sideload unit tests pass, and git diff --check passes. This is a useful fix once these final race conditions are handled.
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
area: androidChanges to the Android app or Gradle build
2 participants
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.
Fixes #582
Summary
Finalize the current episode's playback state before navigating to the next episode.
The existing Next Episode flow can replace the current Player destination before its asynchronous
saveProgress()work finishes, which may cancel the watched/scrobble update with the oldPlayerViewModel.Changes
saveProgressAndWait()to wait for the final playback save;onPlayNext();MediaNext, and the explicit Next Episode button;