Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changes/macos-fullscreen.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
wry: patch
---

Enable WebView element fullscreen support on macOS 12.3+ and iOS 15.4+ without using private APIs. Support for older OS versions is still behind the `fullscreen` feature flag.
Enable WebView element fullscreen support on macOS 12.3+ and iOS 15.4+ without using private APIs.
5 changes: 5 additions & 0 deletions .changes/remove-macos-private-api-feature-flags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
wry: minor
---

**Breaking Change:** Removed the macOS/iOS specific `transparent` and `fullscreen` feature flags. The functionalities are now always enabled. Please reach out immediatly if you see issues in the App Store submission process.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ default = ["protocol", "os-webview", "x11"]
serde = ["dpi/serde"]
protocol = []
devtools = []
transparent = []
fullscreen = []
linux-body = ["webkit2gtk/v2_40", "os-webview"]
mac-proxy = []
os-webview = [
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,6 @@ Wry uses a set of feature flags to toggle several advanced features.
interacting with the window.
- `devtools`: Enables devtools on release builds. Devtools are always enabled in debug builds.
On **macOS**, enabling devtools, requires calling private functions, so avoid this in release builds if you publish your app on the App Store.
- `transparent`: Transparent background on **macOS** requires calling private functions.
Comment thread
FabianLars marked this conversation as resolved.
Avoid this in release builds if you publish your app on the App Store.
- `fullscreen`: Fullscreen video and other media elements on **macOS** < 12.3 and **iOS** < 15.4 requires calling private functions.
Avoid this in release builds if you publish your app on the App Store.
- `linux-body`: Enables body support of custom protocol request on Linux. Requires
WebKit2GTK v2.40 or above.
- `tracing`: enables [`tracing`] for `evaluate_script`, `ipc_handler`, and `custom_protocols`.
Expand Down
1 change: 0 additions & 1 deletion examples/transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ fn main() -> wry::Result<()> {

let builder = WebViewBuilder::new()
// The second is on webview...
// Feature `transparent` is required for transparency to work.
.with_transparent(true)
// And the last is in html.
.with_html(
Expand Down
4 changes: 0 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,6 @@
//! - `devtools`: Enables devtools on release builds. Devtools are always enabled in debug builds.
//! On **macOS**, enabling devtools, requires calling private APIs so you should not enable this flag in release
//! build if your app needs to publish to App Store.
//! - `transparent`: Transparent background on **macOS** requires calling private functions.
//! Avoid this in release build if your app needs to publish to App Store.
//! - `fullscreen`: Fullscreen video and other media on **macOS** requires calling private functions.
//! Avoid this in release build if your app needs to publish to App Store.
//! - `linux-body`: Enables body support of custom protocol request on Linux. Requires
//! WebKit2GTK v2.40 or above.
//! - `tracing`: enables [`tracing`] for `evaluate_script`, `ipc_handler`, and `custom_protocols`.
Expand Down
31 changes: 13 additions & 18 deletions src/wkwebview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ impl InnerWebView {
data_store.setValue_forKey(Some(&proxies), ns_string!("proxyConfigurations"));
}

// NOTE: Private API — `allowsPictureInPictureMediaPlayback` is a private KVC key on WKPreferences.
// NOTE: Private API on macOS — `allowsPictureInPictureMediaPlayback` is a private KVC key on WKPreferences.
// On iOS it's public <https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/allowspictureinpicturemediaplayback>
_preference.setValue_forKey(
Some(&_yes),
ns_string!("allowsPictureInPictureMediaPlayback"),
Expand All @@ -367,16 +368,10 @@ impl InnerWebView {

let version = util::operating_system_version();

#[cfg(feature = "transparent")]
if attributes.transparent || attributes.background_color.is_some() {
let no = NSNumber::numberWithBool(false);
{
if cfg!(target_os = "ios") || version.0 > 10 || (version.0 == 10 && version.1 >= 14) {

@FabianLars FabianLars Jul 22, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never saw a crashlog (from that single user) that made the version check required here for macOS. None of the other kvc uses ever caused version specific crashes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm.. let's give it a shot

// NOTE: Private API — `drawsBackground`.
// Available: macOS 10.14+ (no public doc).
config.setValue_forKey(Some(&no), ns_string!("drawsBackground"));
}
}
// TODO: Check if this property exists or is used on iOS
config.setValue_forKey(Some(&no), ns_string!("drawsBackground"));
}

if (cfg!(target_os = "macos") && (version.0 > 12 || (version.0 == 12 && version.1 >= 3)))
Expand All @@ -385,13 +380,13 @@ impl InnerWebView {
// NOTE: Public API alternative for private config fullScreenEnabled (see below)
// Only available on macOS 12.3+ and iOS 15.4+
_preference.setElementFullscreenEnabled(true);
} else {
// NOTE: Private API — `fullScreenEnabled` is a private KVC key on WKPreferences.
// This is the private API alternative to setElementFullscreenEnabled above that also works on older macOS/iOS versions.
// TODO: Remove this for Tauri v3?
_preference.setValue_forKey(Some(&_yes), ns_string!("fullScreenEnabled"));
}

#[cfg(feature = "fullscreen")]
// NOTE: Private API — `fullScreenEnabled` is a private KVC key on WKPreferences.
// This is the private API alternative to setElementFullscreenEnabled above that also works on older macOS/iOS versions.
_preference.setValue_forKey(Some(&_yes), ns_string!("fullScreenEnabled"));

#[cfg(target_os = "macos")]
let webview = {
let window = ns_view.window().unwrap();
Expand Down Expand Up @@ -543,15 +538,15 @@ impl InnerWebView {
if attributes.devtools {
// <https://developer.apple.com/documentation/webkit/wkwebview/isinspectable>
// Available: macOS 13.3+, iOS 16.4+
// Enables debugging via Safari's Web Inspector, NOT via in-webview devtools.
let has_inspectable_property: bool =
NSObject::respondsToSelector(&webview, objc2::sel!(setInspectable:));
if has_inspectable_property {
webview.setInspectable(true);
}
// NOTE: Private API — `developerExtrasEnabled` is a private KVC key on WKPreferences.
// this cannot be on an `else` statement, it does not work on macOS :(
let dev = ns_string!("developerExtrasEnabled");
_preference.setValue_forKey(Some(&_yes), dev);
// This enables the in-webview devtools
_preference.setValue_forKey(Some(&_yes), ns_string!("developerExtrasEnabled"));
}

// Message handler
Expand Down Expand Up @@ -986,7 +981,7 @@ r#"Object.defineProperty(window, 'ipc', {
self.webview.setBackgroundColor(Some(&color));
}

#[cfg(all(target_os = "macos", feature = "transparent"))]
#[cfg(target_os = "macos")]
unsafe {
let (red, green, blue, alpha) = _background_color;

Expand Down
Loading