Skip to content

fix(playback): UI returns ~1s on title mismatch (was 15s)#813

Merged
mholzi merged 1 commit intomainfrom
fix/playback-confirm-on-title-advance
Apr 28, 2026
Merged

fix(playback): UI returns ~1s on title mismatch (was 15s)#813
mholzi merged 1 commit intomainfrom
fix/playback-confirm-on-title-advance

Conversation

@mholzi
Copy link
Copy Markdown
Owner

@mholzi mholzi commented Apr 28, 2026

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_state now 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

Versions

  • manifest.json + sw.js CACHE_VERSION3.3.2-rc13. No frontend asset changes.

Test plan

  • pytest tests/unit/ — 440 passed (+1 new), 1 xfailed.
  • ruff check + ruff format --check — clean.
  • New test test_ma_fast_path_accepts_title_advanced_without_exact_match covers the German/English title-mismatch case explicitly.
  • @Levtos retests on rc13 — pressing "Next song" should bring the game screen up within ~1-2s.

🤖 Generated with Claude Code

…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>
@mholzi mholzi merged commit 4726a6c into main Apr 28, 2026
7 checks passed
@mholzi mholzi deleted the fix/playback-confirm-on-title-advance branch April 28, 2026 08:08
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant