fix(playback): UI returns ~1s on title mismatch (was 15s)#813
Merged
Conversation
…mismatch @Levtos reported (rc12 playthrough) that pressing "Next song" caused the game screen to lag a few seconds before appearing — even though the music started immediately. Logs showed: MA playback not confirmed after 15.0s for apple_music://track/... Title moved 'Manhattan Skyline' → 'The Model'. Continuing anyway — MA may still be buffering. (#345) Two-part fix: 1. _check_state fast-path now also accepts "title moved to anything different from before the call" (in addition to the existing "title contains expected" substring check). When the playlist has "Das Modell" but Apple Music returns "The Model", or "Hallelujah" becomes "Hallelujah - Live", the substring check fails — but the speaker IS playing a new track. Promoted the same signal that the slow-buffer fallback was using into the fast-path so the UI returns in ~1s instead of waiting the full 15s timeout. #795 invariant preserved: if title is unchanged from before, the fast-path still rejects. Existing tests pass. 2. METADATA_WAIT_TIMEOUT 5s → 2s. Secondary contributor to the lag once the fast-path was firing. On timeout, fall back to the playlist's existing album_art field; briefly stale art at the top of a round in worst case, but the speaker corrects on its own. 440 passed, 1 xfailed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the version to 3.3.2-rc13 and addresses UI lag issues occurring after song transitions. Specifically, it relaxes the _check_state logic in the media player service to accept any title change as a successful playback signal, preventing unnecessary 15-second timeouts when metadata doesn't match exactly. Additionally, the metadata fetch timeout has been reduced from 5 seconds to 2 seconds to further improve responsiveness. A new unit test was added to cover the title mismatch scenario. I have no feedback to provide.
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.
Summary
@Levtos reported on rc12 that pressing "Next song" caused the game screen to lag a few seconds before appearing — even though the music started immediately. Logs showed:
```
MA playback not confirmed after 15.0s for apple_music://track/...
Title moved 'Manhattan Skyline' → 'The Model'.
Continuing anyway — MA may still be buffering. (#345)
```
The track was playing fine. The wait timed out because `expected_lower in current_title.lower()` failed — the playlist had a slightly different title format (German vs English, remaster suffix, "(Live)" version, etc.).
Fix
1. Relaxed fast-path —
_check_statenow also accepts "title moved to anything different from before the call" (in addition to the existing substring-match path). Same signal the slow-buffer fallback was using, promoted into the fast-path. UI returns in ~1s.2. Reduced metadata-fetch timeout 5s → 2s. Secondary contributor to the lag. On timeout, fall back to playlist's existing album_art.
Invariants preserved
test_ma_returns_false_when_title_unchanged_but_position_advancesstill passes.Versions
manifest.json+sw.js CACHE_VERSION→3.3.2-rc13. No frontend asset changes.Test plan
pytest tests/unit/— 440 passed (+1 new), 1 xfailed.ruff check+ruff format --check— clean.test_ma_fast_path_accepts_title_advanced_without_exact_matchcovers the German/English title-mismatch case explicitly.🤖 Generated with Claude Code