[Bug] Headset Play after app update can resume current book at 0:00 #43
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Classification
Playback-correctness field regression. Investigated read-only against
mainatacccd7c3bccc148038539a581736a0d563686622, after GitHub PR #93 was merged.No implementation branch or PR was opened as part of this investigation.
Field report
After BookWave had been updated, while the current audiobook was not open in the foreground, pressing Play on a headset resumed the same audiobook from the beginning (0:00) instead of the listener's existing position.
This was not observed during the GitHub PR #93 acceptance testing.
Expected behavior
A physical headset/Bluetooth Play after package update, service recreation or process replacement must resume the remembered/current audiobook at a trustworthy synchronized position. It must not silently start at
0:00unless zero is genuinely the intended stored position.Why this is separate from #24 / BW-PLAY-01
#24 owns which audiobook this phone remembers. In this field report, the correct audiobook was selected but the position was wrong. Position freshness/resumption correctness remains a separate playback concern.
Current investigation
1. The reported path is the cold/empty Media3 playback-resumption path
ResumeFreshnessPlayer.handleSetPlayWhenReady(true)deliberately forwards Play directly whenmediaItemCount == 0, leaving Media3 to invoke normal playback resumption. That means an empty service does not run the ordinary loaded-item freshness preparation first.The direct unit test named
empty session Play preserves Media3 playback resumptionverifies only that Play is forwarded and that the freshness token/preparation is not consumed. It does not exerciseMediaSession.Callback.onPlaybackResumption, a non-zero returned start position, process/service recreation, or a package update.There are currently no playback tests directly referencing
onPlaybackResumptionorMediaItemsWithStartPosition.2. Cold resumption trusts the newly opened queue start
For
onPlaybackResumption(..., isForPlayback = true),PlaybackServiceresolves the last book, callsopenQueue(..., initialPlayWillFollow = true), and returns:The first Play is then intentionally exempted from a second GitHub #93 freshness check because the new
/playsession is considered fresh server evidence.That design is sound only if the position returned by the fresh session/queue is trustworthy.
3. GitHub PR #93 appears to have exposed this lifecycle path rather than directly introducing the zero
Before/after GitHub #93, cold resumption already opened a queue and returned its start position. GitHub PR #93's material change in this branch was to pass
initialPlayWillFollow = trueso the immediately-following Media3 Play would not perform a redundant second freshness check.So the field report is temporally associated with GitHub #93/update, but the current tree does not prove that GitHub #93 itself changed the cold queue's start-position selection to zero.
4. Confirmed shutdown ordering defect can lose the final server position
PlaybackService.onDestroy()currently does this in order:flushProgress()(local record launched asynchronously);sessionSync.onShutdown();sessionSync.attach(null);SessionSyncCoordinator.onShutdown()itself launches onto the application scope and later callscloseCurrent(ServiceShutdown).closeCurrent()needs a player snapshot, andsnapshot()returnsnullwhen the coordinator's player has already been detached.The application scope runs on a
SupervisorJob + Dispatchers.Default, while the snapshot switches back to the main dispatcher. Therefore the shutdown close is not ordered ahead ofattach(null); the final session close/server progress can be dropped during service teardown.There is no direct
SessionSyncCoordinator.onShutdown()test today.This strongly fits a package-update/process-replacement edge because the listener may lose the most recent server-acknowledged position before the next cold headset resume. It does not by itself prove why this particular report landed exactly at
0:00.5. There is also an explicit zero-producing fallback
MediaItems.queueFor()currently uses:When BookWave cannot construct a trustworthy whole-book timeline because track durations force the single-file fallback,
serverStartPositionFor()deliberately returnsnull, and the queue starts at zero to avoid confusing book-relative and file-relative positions.That is a known defensive degradation, but on a cold headset resume it can produce the exact user-visible symptom reported here: correct book, start at
0:00.The current repository evidence is not enough to tell whether this device run hit that fallback or whether
/playitself returned zero/stale progress after the shutdown/lifecycle gap.6. The captured Audiobookshelf contract proves
/playcan return non-zero resume positionsThe repository's captured
item-play.jsonhas bothcurrentTimeandstartTimeat128.25, andPlaybackMappermapsstartTimedirectly intoPlaybackSession.startAt. So a normal fresh/playresponse is capable of supplying a non-zero position.Working diagnosis
This is a real cold-resumption correctness gap, with at least one confirmed lifecycle defect and one existing exact-zero fallback:
0:00mechanism: single-file fallback converts an otherwise non-zero book position to zero;Required diagnostics for reproduction
Keep logging redaction-safe. Capture enough to distinguish:
/playreturnedstartAt;queue.startPositionMshanded to Media3;Do not log titles, URLs, tokens, raw server identifiers, or private library metadata.
Acceptance criteria for the eventual fix
0:00followed by a later correction.onPlaybackResumptionreturns a non-zero start position and prove the player receives/applies it.onDestroy()as the only durability guarantee.max(local, remote).Related