Skip to content

feat(cef): allow UI audio without a user gesture (autoplay-policy)#234

Open
JEssou115 wants to merge 2 commits into
MafiaHub:developfrom
JEssou115:feat/cef-autoplay-policy
Open

feat(cef): allow UI audio without a user gesture (autoplay-policy)#234
JEssou115 wants to merge 2 commits into
MafiaHub:developfrom
JEssou115:feat/cef-autoplay-policy

Conversation

@JEssou115

@JEssou115 JEssou115 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

What

Adds one Chromium switch in App::OnBeforeCommandLineProcessing:

commandLine->AppendSwitchWithValue("autoplay-policy", "no-user-gesture-required");

Why

CEF views here are host-driven overlays (notifications, HUD, menus). They're rendered by the game and never receive a real user activation (a trusted click/keypress in the page). Chromium's default autoplay policy requires that activation before any audio can play, so all UI sound is silently blocked — both Web Audio (AudioContext.resume() stays suspended) and <audio> playback.

There is no page-side workaround for a passive overlay: it never gets a gesture, and synthetic events don't count as user activation. The autoplay policy is a global command-line switch (not a per-view setting), so this flag is the standard fix — and it enables notification/UI sounds for any resource.

Notes

  • One line, alongside the existing switches (disable-gpu-compositing, disable-extensions, …).
  • Audio-only: it doesn't enable anything else, no rendering/security impact.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Enabled embedded browser media to autoplay without requiring an initial user interaction.

CEF views here are host-driven overlays (notifications, HUD, menus) that
never receive a real user activation, so Chromium's default autoplay policy
silently blocks all sound — both Web Audio (AudioContext stays suspended)
and <audio> playback. Opt the embedded browser out with
--autoplay-policy=no-user-gesture-required so resources can play UI sounds.

There's no page-side workaround for a passive overlay: it never gets a
gesture and synthetic events don't count as activation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

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: 6462e1c6-1215-4fce-91b0-5905eae1b5bc

📥 Commits

Reviewing files that changed from the base of the PR and between ebeb9dd and d616986.

📒 Files selected for processing (1)
  • code/framework/src/gui/cef/app.cpp

Walkthrough

The CEF command-line setup now adds autoplay-policy=no-user-gesture-required, allowing embedded browser audio autoplay without user activation.

Changes

CEF autoplay configuration

Layer / File(s) Summary
Configure autoplay policy
code/framework/src/gui/cef/app.cpp
App::OnBeforeCommandLineProcessing appends the autoplay policy switch while preserving existing switches.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Poem

A rabbit hopped through browser cheer,
And found a switch to make sound clear.
No click, no tap, the tunes now play,
CEF hums along its way.
Boing! config blooms today.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the CEF autoplay-policy change to allow audio without a user gesture.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@zpl-zak

zpl-zak commented Jul 12, 2026

Copy link
Copy Markdown
Member

Not sure about this one. I think this should be an opt-in feature that the multiplayer client would enable selectively.

Then, each multiplayer client should ideally have a settings menu where this feature can be enabled or disabled.

This is to avoid potential abuse on malicious servers. We shouldn't trust the user-generated content that much.

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