Summary
Wails currently constructs WKWebViewConfiguration on macOS but never exposes two important media-playback properties. This makes it impossible to let media autoplay without a user gesture in a Wails macOS application.
Affected properties
| Property |
What it controls |
WKWebViewConfiguration.mediaTypesRequiringUserActionForPlayback |
Whether audio/video requires a user gesture before playback. Set to WKAudiovisualMediaTypeNone (0) to allow autoplay. |
WKWebViewConfiguration.allowsInlineMediaPlayback |
Whether video plays inline (inside the page) rather than full-screen. |
Use cases blocked today
- Kiosk / digital-signage apps with ambient background video
- Media players that should start playing on load
- WebRTC self-preview (camera stream) that starts without a click
- Any page that uses
<video autoplay> or the Web Audio API
Current state
v2 (stable): WailsContext.m allocates WKWebViewConfiguration and applies suppressesIncrementalRendering, user-agent, scheme handlers, and a small set of WKPreferences flags — but not the two media properties.
v3 (alpha): webview_window_darwin.go passes a struct WebviewPreferences through to windowNew() in Objective-C and applies TabFocusesLinks, TextInteractionEnabled, FullscreenEnabled, and AllowsBackForwardNavigationGestures — but again, not the media properties.
Precedent: iOS already does this
v3/pkg/application/webview_window_ios.m (lines inside viewDidLoad) already sets both properties based on options passed from Go:
config.allowsInlineMediaPlayback = ios_is_inline_media_playback_enabled();
if (ios_is_autoplay_without_user_action_enabled()) {
config.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
} else {
config.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll;
}
These are exposed in application_options.go as:
EnableInlineMediaPlayback bool
EnableAutoplayWithoutUserAction bool
macOS should have the equivalent options.
Related
Proposed fix
Add two new u.Bool fields to MacWebviewPreferences (v3) and mac.Preferences (v2), extend the C struct Preferences / struct WebviewPreferences conduit, and apply the properties in the Objective-C WKWebViewConfiguration setup block — mirroring exactly what iOS already does.
Defaults preserve current behaviour (WebKit requires a user gesture unless the app explicitly opts in).
I have a fork with both v2 and v3 branches ready. Happy to open PRs once this issue is acknowledged.
Summary
Wails currently constructs
WKWebViewConfigurationon macOS but never exposes two important media-playback properties. This makes it impossible to let media autoplay without a user gesture in a Wails macOS application.Affected properties
WKWebViewConfiguration.mediaTypesRequiringUserActionForPlaybackWKAudiovisualMediaTypeNone(0) to allow autoplay.WKWebViewConfiguration.allowsInlineMediaPlaybackUse cases blocked today
<video autoplay>or the Web Audio APICurrent state
v2 (stable):
WailsContext.mallocatesWKWebViewConfigurationand appliessuppressesIncrementalRendering, user-agent, scheme handlers, and a small set ofWKPreferencesflags — but not the two media properties.v3 (alpha):
webview_window_darwin.gopasses astruct WebviewPreferencesthrough towindowNew()in Objective-C and appliesTabFocusesLinks,TextInteractionEnabled,FullscreenEnabled, andAllowsBackForwardNavigationGestures— but again, not the media properties.Precedent: iOS already does this
v3/pkg/application/webview_window_ios.m(lines insideviewDidLoad) already sets both properties based on options passed from Go:These are exposed in
application_options.goas:macOS should have the equivalent options.
Related
Proposed fix
Add two new
u.Boolfields toMacWebviewPreferences(v3) andmac.Preferences(v2), extend the Cstruct Preferences/struct WebviewPreferencesconduit, and apply the properties in the Objective-CWKWebViewConfigurationsetup block — mirroring exactly what iOS already does.Defaults preserve current behaviour (WebKit requires a user gesture unless the app explicitly opts in).
I have a fork with both v2 and v3 branches ready. Happy to open PRs once this issue is acknowledged.