Skip to content

Fix ~1s audio dropout on library long-press (spurious engine configuration change) - #110

Merged
sanylax0 merged 1 commit into
mainfrom
claude/repo-review-improvements-yvk3t7-haptic-dropout
Jul 20, 2026
Merged

sanylax0 merged 1 commit into
mainfrom
claude/repo-review-improvements-yvk3t7-haptic-dropout

Conversation

@sanylax2

Copy link
Copy Markdown
Collaborator

Root cause

Long-pressing a song row opens a context menu, which fires the system haptic. On iPhone the Taptic Engine shares the audio hardware, and engaging it can post AVAudioEngineConfigurationChange while the engine is still rendering normally — a spurious notification.

Our handler in Player+AudioSession.swift recovered unconditionally: recoverPlayback(force: true) stops both stem players, reschedules from the current position, and restarts. That teardown/rebuild is the audible ~1-second cutout.

Fix

Guard the recovery on engine.isRunning: if the engine is still running when the notification arrives, the audio was never affected — log and skip. Real configuration changes (route switches, sample-rate changes) genuinely stop the engine, so they recover exactly as before. The interruption, route-loss, and media-services-reset paths are untouched.

Device check

  • Play a track, long-press a song in the library → context menu opens with no audio hiccup; console shows engine configuration change — engine still running, skipping recovery if the spurious notification fired.
  • Regression: switch output devices (speaker ↔ Bluetooth ↔ wired) mid-song → playback still recovers and continues.

🤖 Generated with Claude Code

https://claude.ai/code/session_013TJoWkqg8bzkGdzxWhWjWP


Generated by Claude Code

…opout)

Long-pressing a library row fires the context-menu haptic; the Taptic
Engine shares the audio hardware and can post
AVAudioEngineConfigurationChange while the engine is still rendering.
The handler recovered unconditionally — stop + reschedule both stem
players — turning a harmless notification into an audible ~1s dropout.
Recover only when the engine actually stopped; real route/sample-rate
changes still recover exactly as before.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013TJoWkqg8bzkGdzxWhWjWP

@sanylax0 sanylax0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@sanylax0
sanylax0 merged commit df40bb4 into main Jul 20, 2026
1 of 4 checks passed
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.

3 participants