Skip to content

fix: unlock audio context so UI sounds play on deploy - #25

Merged
ShreyashSri merged 1 commit into
stagingfrom
landing-page
Jun 19, 2026
Merged

fix: unlock audio context so UI sounds play on deploy#25
ShreyashSri merged 1 commit into
stagingfrom
landing-page

Conversation

@sxivansx

Copy link
Copy Markdown
Collaborator

Problem

UI interaction sounds (from the Tone.js useRetroSound engine merged in #22) do not play on the live deployment.

Root cause

mouseenter (hover) is not a valid user-activation gesture for resuming a Web Audio context. The engine called Tone.start() on the first interaction and immediately latched a started = true flag. When that first interaction was a hover (almost always, before any click), the context stayed suspended but the flag was set — so every subsequent click short-circuited and audio never played.

Fix

  • Re-check the real Tone.getContext().state on every call instead of latching a started flag; keep retrying Tone.start() until the context is actually running.
  • Build the synth nodes only once the context is genuinely running.
  • Add document-level pointerdown / touchstart / keydown listeners so the first genuine gesture anywhere on the page unlocks audio (and detach them once unlocked).

One file changed: components/landing/hooks/useRetroSound.ts.

Test

  • tsc --noEmit passes.
  • Verified the hook no longer references the started/booting latch and now resumes on real gestures.

🤖 Generated with Claude Code

mouseenter is not a valid user-activation gesture, so a hover before the
first click left the AudioContext suspended while the engine latched a
"started" flag and never retried — silencing all sounds. Re-check the real
context state on every call and add document-level pointerdown/touchstart/
keydown listeners that unlock audio on the first genuine gesture anywhere.
@ShreyashSri
ShreyashSri merged commit aa2eee3 into staging Jun 19, 2026
4 checks passed
@ShreyashSri
ShreyashSri deleted the landing-page branch June 20, 2026 18:24
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.

2 participants