Skip to content

Sound error fixed#3961

Open
sardidefcon wants to merge 1 commit into
openfrontio:mainfrom
sardidefcon:fix-exit-button-sounds
Open

Sound error fixed#3961
sardidefcon wants to merge 1 commit into
openfrontio:mainfrom
sardidefcon:fix-exit-button-sounds

Conversation

@sardidefcon
Copy link
Copy Markdown
Contributor

Description:

Sound bug fixed: When the button to exit a game is clicked and the action is canceled in the confirmation dialog, the background music and sound effects stop playing for the rest of the game.

Clicking "Exit" brings up a native browser confirmation dialog. This dialog causes the window to lose focus, and the browser takes the opportunity to suspend Howler's audio context. The curious thing is that this suspension doesn't happen while the dialog is open, but right after closing it. If you confirmed, it wasn't noticeable because the page reloaded anyway. But if you canceled, you were left in the game with the audio suspended, and nothing could reactivate it, so the music and sound effects were muted for the rest of the game.

Canceling simply resumes the audio if it was paused. Since the pause occurs a moment late, it's not enough to do it immediately; we do it when the window regains focus (which is precisely when the dialogue closes) and, just in case, with a short timer backup. This way, the sound returns automatically and the game continues normally.

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

Please put your Discord username so you can be contacted if a bug or regression is found:

sardidefcon

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0ff48338-91e3-45d4-9ee6-fc21abeab503

📥 Commits

Reviewing files that changed from the base of the PR and between 2e17fb5 and f4a2d9c.

📒 Files selected for processing (1)
  • src/client/graphics/layers/GameRightSidebar.ts

Walkthrough

GameRightSidebar adds Howler audio context resumption to its exit dialog cancel flow. When the user cancels the exit confirmation, the handler now registers a window focus listener and schedules a timeout to resume the suspended Web Audio context before returning.

Changes

Audio Context Resumption

Layer / File(s) Summary
Audio context resume on exit dialog cancel
src/client/graphics/layers/GameRightSidebar.ts
Howler is imported to support audio context management. A new resumeAudioContext() helper resumes the suspended Web Audio context. The onExitButtonClick() cancel-confirmation branch now registers a one-time window focus listener and schedules a 1s timeout fallback to resume audio before returning, ensuring playback is available when the user dismisses the exit dialog.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🎵 When users cancel their escape,
The audio wakes from its slumber,
A focus listener and timeout's grace,
Keep the Howler's voice in number!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Sound error fixed' is directly related to the changeset, which fixes an audio/sound issue when canceling the exit confirmation dialog.
Description check ✅ Passed The description is thorough and clearly related to the changeset, explaining the bug (suspended audio context after canceling exit), the fix (resuming audio on window focus with a timer backup), and testing confirmation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant