Skip to content

Commit ee0fb97

Browse files
docs(windows): add notice about different data dir (#1681)
* docs(windows): add notice about different data dir * Document underlying reason * Fix auto links
1 parent a7de137 commit ee0fb97

4 files changed

Lines changed: 34 additions & 21 deletions

File tree

src/custom_protocol_workaround.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! - WebView2 supports non-standard protocols only on Windows 10+, so we have to use a workaround.
2-
//! See https://github.com/MicrosoftEdge/WebView2Feedback/issues/73
2+
//! See <https://github.com/MicrosoftEdge/WebView2Feedback/issues/73>
33
//! - On Android, there's no API for registering custom protocols, so this workaround is also used.
44
//!
55
//! The process looks like this:

src/lib.rs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
//!
7575
//! ## Child webviews
7676
//!
77-
//! You can use [`WebView::new_as_child`] or [`WebViewBuilder::new_as_child`] to create the webview as a child inside another window. This is supported on
77+
//! You can use [`WebView::new_as_child`] or [`WebViewBuilder::build_as_child`] to create the webview as a child inside another window. This is supported on
7878
//! macOS, Windows and Linux (X11 Only).
7979
//!
8080
//! ```no_run
@@ -737,7 +737,7 @@ pub struct WebViewAttributes<'a> {
737737
/// ## Platform-specific:
738738
///
739739
/// - Windows: Setting to `false` does nothing on WebView2 Runtime version before 92.0.902.0,
740-
/// see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10902-prerelease
740+
/// see <https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10902-prerelease>
741741
///
742742
/// - **Android / iOS:** Unsupported.
743743
pub back_forward_navigation_gestures: bool,
@@ -751,7 +751,7 @@ pub struct WebViewAttributes<'a> {
751751
/// ## Platform-specific:
752752
///
753753
/// - **Windows**: Requires WebView2 Runtime version 101.0.1210.39 or higher, does nothing on older versions,
754-
/// see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10121039
754+
/// see <https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10121039>
755755
/// - **Android:** Unsupported yet.
756756
/// - **macOS / iOS**: Uses the nonPersistent DataStore.
757757
pub incognito: bool,
@@ -792,7 +792,7 @@ pub struct WebViewAttributes<'a> {
792792
/// - **iOS**: Supported since version 17.0+.
793793
/// - **macOS**: Supported since version 14.0+.
794794
///
795-
/// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578
795+
/// see <https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578>
796796
pub background_throttling: Option<BackgroundThrottlingPolicy>,
797797

798798
/// Whether JavaScript should be disabled.
@@ -1239,7 +1239,7 @@ impl<'a> WebViewBuilder<'a> {
12391239
/// ## Platform-specific
12401240
///
12411241
/// - Windows: Requires WebView2 Runtime version 86.0.616.0 or higher, does nothing on older versions,
1242-
/// see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10790-prerelease
1242+
/// see <https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10790-prerelease>
12431243
pub fn with_user_agent(mut self, user_agent: impl Into<String>) -> Self {
12441244
self.attrs.user_agent = Some(user_agent.into());
12451245
self
@@ -1266,7 +1266,7 @@ impl<'a> WebViewBuilder<'a> {
12661266
/// ## Platform-specific
12671267
///
12681268
/// - Windows: Setting to `false` can't disable pinch zoom on WebView2 Runtime version before 91.0.865.0,
1269-
/// see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10865-prerelease
1269+
/// see <https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10865-prerelease>
12701270
///
12711271
/// - **macOS / Linux / Android / iOS**: Unsupported
12721272
pub fn with_hotkeys_zoom(mut self, zoom: bool) -> Self {
@@ -1373,7 +1373,7 @@ impl<'a> WebViewBuilder<'a> {
13731373
/// ## Platform-specific:
13741374
///
13751375
/// - Windows: Requires WebView2 Runtime version 101.0.1210.39 or higher, does nothing on older versions,
1376-
/// see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10121039
1376+
/// see <https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10121039>
13771377
/// - **Android:** Unsupported yet.
13781378
pub fn with_incognito(mut self, incognito: bool) -> Self {
13791379
self.attrs.incognito = incognito;
@@ -1430,7 +1430,7 @@ impl<'a> WebViewBuilder<'a> {
14301430
/// - **iOS**: Supported since version 17.0+.
14311431
/// - **macOS**: Supported since version 14.0+.
14321432
///
1433-
/// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578
1433+
/// see <https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578>
14341434
pub fn with_background_throttling(mut self, policy: BackgroundThrottlingPolicy) -> Self {
14351435
self.attrs.background_throttling = Some(policy);
14361436
self
@@ -1721,7 +1721,7 @@ pub trait WebViewBuilderExtWindows {
17211721
///
17221722
/// ## Warning
17231723
///
1724-
/// - Webview instances with different browser arguments must also have different [data directories](struct.WebContext.html#method.new).
1724+
/// - Webview instances with different browser arguments must also have different [data directories](WebContext::new).
17251725
/// - By default wry passes `--disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection`
17261726
/// `--autoplay-policy=no-user-gesture-required` if autoplay is enabled
17271727
/// and `--proxy-server=<scheme>://<host>:<port>` if a proxy is set.
@@ -1733,7 +1733,7 @@ pub trait WebViewBuilderExtWindows {
17331733
/// The default value is `true`. See the following link to know more details.
17341734
///
17351735
/// Setting to `false` does nothing on WebView2 Runtime version before 92.0.902.0,
1736-
/// see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10824-prerelease
1736+
/// see <https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10824-prerelease>
17371737
///
17381738
/// <https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2settings#arebrowseracceleratorkeysenabled>
17391739
fn with_browser_accelerator_keys(self, enabled: bool) -> Self;
@@ -1751,7 +1751,7 @@ pub trait WebViewBuilderExtWindows {
17511751
/// Defaults to [`Theme::Auto`] which will follow the OS defaults.
17521752
///
17531753
/// Requires WebView2 Runtime version 101.0.1210.39 or higher, does nothing on older versions,
1754-
/// see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10121039
1754+
/// see <https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10121039>
17551755
fn with_theme(self, theme: Theme) -> Self;
17561756

17571757
/// Determines whether the custom protocols should use `https://<scheme>.path/to/page` instead of the default `http://<scheme>.path/to/page`.
@@ -1765,18 +1765,26 @@ pub trait WebViewBuilderExtWindows {
17651765
/// Specifies the native scrollbar style to use with webview2.
17661766
/// CSS styles that modify the scrollbar are applied on top of the native appearance configured here.
17671767
///
1768-
/// Defaults to [`ScrollbarStyle::Default`] which is the browser default used by Microsoft Edge.
1768+
/// Defaults to [`ScrollBarStyle::Default`] which is the browser default used by Microsoft Edge.
17691769
///
17701770
/// Requires WebView2 Runtime version 125.0.2535.41 or higher, does nothing on older versions,
1771-
/// see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/?tabs=dotnetcsharp#10253541
1771+
/// see <https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/?tabs=dotnetcsharp#10253541>
1772+
///
1773+
/// ## Warning
1774+
///
1775+
/// Webview instances with different scroll bar styles must also have different [data directories](WebContext::new).
17721776
fn with_scroll_bar_style(self, style: ScrollBarStyle) -> Self;
17731777

17741778
/// Determines whether the ability to install and enable extensions is enabled.
17751779
///
17761780
/// By default, extensions are disabled.
17771781
///
1778-
/// Requires WebView2 Runtime version 1.0.2210.55 or higher, does nothing on older versions,
1779-
/// see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10221055
1782+
/// Requires WebView2 Runtime version 120.0.2210.55 or higher, does nothing on older versions,
1783+
/// see <https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10221055>
1784+
///
1785+
/// ## Warning
1786+
///
1787+
/// Webview instances with different browser extensions enabled settings must also have different [data directories](WebContext::new).
17801788
fn with_browser_extensions_enabled(self, enabled: bool) -> Self;
17811789

17821790
/// Set the path from which to load extensions from. Extensions stored in this path should be unpacked.
@@ -2286,7 +2294,7 @@ pub trait WebViewExtWindows {
22862294
/// Changes the webview2 theme.
22872295
///
22882296
/// Requires WebView2 Runtime version 101.0.1210.39 or higher, returns error on older versions,
2289-
/// see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10121039
2297+
/// see <https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10121039>
22902298
fn set_theme(&self, theme: Theme) -> Result<()>;
22912299

22922300
/// Sets the [memory usage target level][1].

src/web_context.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use std::{
1616
/// private/incognito tabs.
1717
///
1818
/// # Warning
19+
///
1920
/// If [`WebView`] is created by a WebContext. Dropping `WebContext` will cause [`WebView`] lose
2021
/// some actions like custom protocol on Mac. Please keep both instances when you still wish to
2122
/// interact with them.
@@ -33,9 +34,14 @@ pub struct WebContext {
3334
impl WebContext {
3435
/// Create a new [`WebContext`].
3536
///
36-
/// `data_directory`:
37-
/// * Whether the WebView window should have a custom user data path. This is useful in Windows
38-
/// when a bundled application can't have the webview data inside `Program Files`.
37+
/// - `data_directory`: Whether the WebView window should have a custom user data path.
38+
/// This is useful in Windows when a bundled application can't have the webview data inside `Program Files`.
39+
///
40+
/// ## Platform-specific:
41+
///
42+
/// - **Windows**: Webview instances with different `CoreWebView2EnvironmentOptions` must have different `data_directory`s [^1]
43+
///
44+
/// [^1]: <https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2environment.createcorewebview2controllerasync?view=webview2-dotnet-1.0.3719.77#:~:text=WebView%20creation%20fails%20if%20a%20running%20instance%20using%20the%20same%20user%20data%20folder%20exists%2C%20and%20the%20Environment%20objects%20have%20different%20CoreWebView2EnvironmentOptions.>
3945
pub fn new(data_directory: Option<PathBuf>) -> Self {
4046
Self {
4147
os: WebContextImpl::new(data_directory.as_deref()),

src/webview2/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ impl InnerWebView {
294294
let additional_browser_args = pl_attrs.additional_browser_args.unwrap_or_else(|| {
295295
// remove "mini menu" - See https://github.com/tauri-apps/wry/issues/535
296296
// and "smart screen" - See https://github.com/tauri-apps/tauri/issues/1345
297-
// enable white flicker fix
298297
let default_args = "--disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection";
299298
let mut arguments = String::from(default_args);
300299

0 commit comments

Comments
 (0)