Skip to content

Conversation

lucasfernog
Copy link
Member

on Windows the Webview2 environment options must match when created webviews sharing the same data directory (unless specified, all webviews share the same data directory). This PR validates the options, warning if they do not match, and forces the webview to be created with the same previous environment to prevent a crash.

discovered as part of #14089

on Windows the Webview2 environment options must match when created webviews sharing the same data directory (unless specified, all webviews share the same data directory). This PR validates the options, warning if they do not match, and forces the webview to be created with the same previous environment to prevent a crash.

discovered as part of #14089
@lucasfernog lucasfernog requested a review from a team as a code owner August 28, 2025 16:33
@github-project-automation github-project-automation bot moved this to 📬Proposal in Roadmap Aug 28, 2025
Copy link
Contributor

Package Changes Through 059bafa

There are 5 changes which include @tauri-apps/cli with patch, tauri-cli with patch, tauri with patch, tauri-build with patch, tauri-runtime-wry with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tauri-runtime-wry 2.8.1 2.8.2
tauri-build 2.4.0 2.4.1
tauri 2.8.4 2.8.5
@tauri-apps/cli 2.8.3 2.8.4
tauri-cli 2.8.3 2.8.4

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

Copy link
Contributor

@Legend-Master Legend-Master left a comment

Choose a reason for hiding this comment

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

I think with this, we should update the documentation webview_attributes.environment and related function, then mark NewWindowOpener.environment as deprecated since we now pass them automatically now and you can't use a different one within the same data directory anyways


#[cfg(windows)]
#[derive(Debug, PartialEq, Eq)]
struct WebView2EnvironmentOptions {
Copy link
Contributor

Choose a reason for hiding this comment

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

To be honest, this feels very error prune to me but I don't know if there's a better way

Copy link
Member Author

Choose a reason for hiding this comment

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

well this is just for the warning - we ALWAYS force the same environment for the same data directory

Comment on lines +165 to +166
#[cfg(windows)]
environment_options: WebView2EnvironmentOptions,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe?

Suggested change
#[cfg(windows)]
environment_options: WebView2EnvironmentOptions,
#[cfg(all(debug_assertions, windows))]
environment_options: WebView2EnvironmentOptions,


#[cfg(windows)]
if let Some(environment) = &web_context.environment {
webview_builder = webview_builder.with_environment(environment.clone());
Copy link
Contributor

Choose a reason for hiding this comment

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

The whole environment thing is a bit confusing now, that we have it in on_new_window and tell people to pass it in with with_environment/window_features, but we also have it done automatically here

Some documentation around the related attributes would be nice

Copy link
Member Author

Choose a reason for hiding this comment

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

well i'm not sure if we should be explicit or not. like only validate the environment options matches? though in this case we get to that "error prune" validation issue..

since the on_new_window environment is all handled by window_features i think it's ok to keep it as is, so it's explicitly matched instead of relying on internal details

but i agree documentation should be improved anyway

Copy link
Contributor

Choose a reason for hiding this comment

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

well i'm not sure if we should be explicit or not. like only validate the environment options matches? though in this case we get to that "error prune" validation issue..

I think forcing the same environment makes sense here, no matter the options, it's too error prune the other way around

since the on_new_window environment is all handled by window_features i think it's ok to keep it as is, so it's explicitly matched instead of relying on internal details

If we want to force the environment, keeping it feels like some extra confusions, anyways, we can't remove it in v2 anyways, let's just update documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📬Proposal

Development

Successfully merging this pull request may close these issues.

2 participants