feat(mac/v2): expose mediaTypesRequiringUserActionForPlayback on WKWebView#5512
feat(mac/v2): expose mediaTypesRequiringUserActionForPlayback on WKWebView#5512Eyalm321 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughThis PR adds macOS media autoplay support to Wails v2 by introducing a new user-facing preference, bridging it through C to Objective-C, and applying it directly to WebKit's audio/visual media configuration during window creation. ChangesmacOS Media Autoplay Feature
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
.github/workflows/build-macos-media-playback.yml (1)
18-23: ⚖️ Poor tradeoffConsider pinning actions to commit SHAs.
Pinning to commit hashes prevents supply-chain attacks via tag/version manipulation.
Example with SHA pinning
- - uses: actions/checkout@v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - - uses: actions/setup-go@v5 + - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0You can find the commit SHAs for specific versions in each action's repository release page.
Also applies to: 43-48
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/build-macos-media-playback.yml around lines 18 - 23, Replace floating action tags with immutable commit SHAs: locate the occurrences of "uses: actions/checkout@v4" and "uses: actions/setup-go@v4" (and the other occurrences flagged around lines 43-48) and change them to the corresponding commit SHA references from each action's GitHub repo (e.g., actions/checkout@<commit-sha> and actions/setup-go@<commit-sha>); update the workflow comments to note the chosen SHAs and, if desired, add a short note or workflow-level variable that documents the original tag version for future updates.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/build-macos-media-playback.yml:
- Line 20: Replace the outdated runner reference "uses: actions/setup-go@v4"
with "uses: actions/setup-go@v5" wherever it appears in the workflow (there are
two occurrences of the literal "uses: actions/setup-go@v4"); update both
instances so the workflow uses actions/setup-go@v5.
- Line 18: Update the checkout steps that use the action identifier "uses:
actions/checkout@v4" to include the option persist-credentials: false so
credentials are not persisted in the workspace; apply this change to each
checkout step occurrence (including the second occurrence referenced in the
review) by adding the persist-credentials: false key under the same job/step
that calls actions/checkout@v4.
- Around line 1-9: Add an explicit top-level GitHub Actions permissions block
for the "Build darwin (media-playback options)" workflow (the YAML with the
name: Build darwin (media-playback options) and the on: section) to restrict the
OIDC token scope; include only the minimal required permissions such as
contents: read and packages: read (and add id-token: write only if the workflow
needs OIDC), placing the permissions stanza at the top-level of the workflow
file.
---
Nitpick comments:
In @.github/workflows/build-macos-media-playback.yml:
- Around line 18-23: Replace floating action tags with immutable commit SHAs:
locate the occurrences of "uses: actions/checkout@v4" and "uses:
actions/setup-go@v4" (and the other occurrences flagged around lines 43-48) and
change them to the corresponding commit SHA references from each action's GitHub
repo (e.g., actions/checkout@<commit-sha> and actions/setup-go@<commit-sha>);
update the workflow comments to note the chosen SHAs and, if desired, add a
short note or workflow-level variable that documents the original tag version
for future updates.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 85a2b43e-54c3-4dce-a8e9-db080071f2e3
📒 Files selected for processing (5)
.github/workflows/build-macos-media-playback.ymlv2/internal/frontend/desktop/darwin/WailsContext.hv2/internal/frontend/desktop/darwin/WailsContext.mv2/internal/frontend/desktop/darwin/window.gov2/pkg/options/mac/preferences.go
20bd946 to
bf58079
Compare
Add EnableAutoplayWithoutUserAction to mac.Preferences, mapping to WKWebViewConfiguration.mediaTypesRequiringUserActionForPlayback. Without this option, there is no way to autoplay HTML5 video/audio in a Wails v2 macOS app — every <video autoplay> is blocked by WebKit's user-gesture requirement. Follows the existing pattern used for TabFocusesLinks, FullscreenEnabled etc.: u.Bool option, bool* in the C struct, applied on WKWebViewConfiguration when set. Defaults preserve current WebKit behaviour (gesture required) — opt-in only. iOS already exposes the equivalent (EnableAutoplayWithoutUserAction in v3 application_options.go); this brings v2 macOS to parity. Closes wailsapp#5511
There was a problem hiding this comment.
♻️ Duplicate comments (3)
.github/workflows/build-macos-media-playback.yml (3)
20-20:⚠️ Potential issue | 🔴 Critical | ⚡ Quick win
actions/setup-go@v4is outdated and can fail the workflow.At Line 20 and Line 45, bump to
actions/setup-go@v5.Suggested patch
- - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 ... - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5Also applies to: 45-45
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/build-macos-media-playback.yml at line 20, Replace the outdated GitHub Actions step using actions/setup-go@v4 with actions/setup-go@v5 in the workflow file: locate the occurrences of the runner step that reads "uses: actions/setup-go@v4" (found at the instances around the top-level steps, including the lines referenced) and update the version tag to "actions/setup-go@v5" for both occurrences so the workflow uses the current setup-go action.
18-18:⚠️ Potential issue | 🟠 Major | ⚡ Quick winDisable credential persistence on checkout.
At Line 18 and Line 43, set
persist-credentials: falseto reduce token exposure across later steps/artifacts.Suggested patch
- uses: actions/checkout@v4 + with: + persist-credentials: false ... - uses: actions/checkout@v4 + with: + persist-credentials: falseAlso applies to: 43-43
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/build-macos-media-playback.yml at line 18, Update the GitHub Actions checkout steps to disable credential persistence by adding persist-credentials: false to each actions/checkout@v4 invocation; specifically modify the checkout step(s) referenced (the steps that call actions/checkout@v4 at both occurrences) to include the persist-credentials: false key so tokens are not automatically persisted to later steps or artifacts.
1-9:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAdd least-privilege workflow permissions.
There is no top-level
permissionsblock, so the workflow inherits broader defaults. Add minimal read-only scope unless a job explicitly needs more.Suggested patch
name: Build darwin (media-playback options) +permissions: + contents: read + on:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/build-macos-media-playback.yml around lines 1 - 9, Add a top-level GitHub Actions permissions block to this workflow (name "Build darwin (media-playback options)") to enforce least-privilege access by setting minimal read-only scopes (e.g., set contents: read) at the root of the YAML; if any job or step (refer to job names in this workflow) requires broader rights, grant only the specific additional permissions on that job via its own permissions map.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In @.github/workflows/build-macos-media-playback.yml:
- Line 20: Replace the outdated GitHub Actions step using actions/setup-go@v4
with actions/setup-go@v5 in the workflow file: locate the occurrences of the
runner step that reads "uses: actions/setup-go@v4" (found at the instances
around the top-level steps, including the lines referenced) and update the
version tag to "actions/setup-go@v5" for both occurrences so the workflow uses
the current setup-go action.
- Line 18: Update the GitHub Actions checkout steps to disable credential
persistence by adding persist-credentials: false to each actions/checkout@v4
invocation; specifically modify the checkout step(s) referenced (the steps that
call actions/checkout@v4 at both occurrences) to include the
persist-credentials: false key so tokens are not automatically persisted to
later steps or artifacts.
- Around line 1-9: Add a top-level GitHub Actions permissions block to this
workflow (name "Build darwin (media-playback options)") to enforce
least-privilege access by setting minimal read-only scopes (e.g., set contents:
read) at the root of the YAML; if any job or step (refer to job names in this
workflow) requires broader rights, grant only the specific additional
permissions on that job via its own permissions map.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 01eaee00-77e6-49e6-bf80-f93f014163cc
📒 Files selected for processing (5)
.github/workflows/build-macos-media-playback.ymlv2/internal/frontend/desktop/darwin/WailsContext.hv2/internal/frontend/desktop/darwin/WailsContext.mv2/internal/frontend/desktop/darwin/window.gov2/pkg/options/mac/preferences.go
✅ Files skipped from review due to trivial changes (1)
- v2/internal/frontend/desktop/darwin/WailsContext.h
🚧 Files skipped from review as they are similar to previous changes (3)
- v2/internal/frontend/desktop/darwin/window.go
- v2/pkg/options/mac/preferences.go
- v2/internal/frontend/desktop/darwin/WailsContext.m
bf58079 to
f39b362
Compare
Pin to a Wails v2 fork that exposes WKWebViewConfiguration.mediaTypesRequiringUserActionForPlayback, then opt in via Mac.Preferences.EnableAutoplayWithoutUserAction. Without this, every <video>/<audio> tag in the embedded webview required a click before playback — making things like ambient bar audio unusable. Fork: github.com/Eyalm321/wails/v2 v2.12.0-mediaplayback.1 Upstream PR: wailsapp/wails#5512 Bumps CI Go to 1.25 to match the fork's go.mod requirement. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pin to a Wails v2 fork that exposes WKWebViewConfiguration.mediaTypesRequiringUserActionForPlayback, then opt in via Mac.Preferences.EnableAutoplayWithoutUserAction. Without this, every <video>/<audio> tag in the embedded webview required a click before playback — making things like ambient bar audio unusable. Fork: github.com/Eyalm321/wails/v2 v2.12.0-mediaplayback.1 Upstream PR: wailsapp/wails#5512 Bumps CI Go to 1.25 to match the fork's go.mod requirement. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Adds
EnableAutoplayWithoutUserActiontomac.Preferences, mapping toWKWebViewConfiguration.mediaTypesRequiringUserActionForPlayback. Without it, there is no way to autoplay HTML5 video/audio in a Wails v2 macOS app — every<video autoplay>is blocked.Closes #5511.
Implementation
Mirrors the existing preference-passing pattern (compare
TabFocusesLinks,FullscreenEnabled):EnableAutoplayWithoutUserAction u.Booltomac.Preferences(v2/pkg/options/mac/preferences.go)bool *enableAutoplayWithoutUserActionto the Cstruct Preferences(WailsContext.h)IsSet()+bool2CboolPtr(...)(window.go)WKWebViewConfigurationwhen set:Defaults preserve WebKit's current behaviour (user gesture required) — opt-in only.
iOS in v3 already exposes the equivalent option (
EnableAutoplayWithoutUserActioninapplication_options.go), and the same gap is being filled for v3 macOS in a parallel PR.Note:
allowsInlineMediaPlaybackis iOS-only onWKWebViewConfiguration(verified by macos-latest compile failure with Xcode 16.4 SDK), so it is intentionally not exposed on macOS.Test plan
macos-latest/ Xcode 16.4)<video autoplay src="...">andMac.Preferences.EnableAutoplayWithoutUserAction: mac.Enabledautoplays without a clickSummary by CodeRabbit
New Features