feat(windows): add with_profile_name for WebView2 multi-profile support#1738
Merged
Legend-Master merged 1 commit intoMay 27, 2026
Merged
Conversation
Contributor
Package Changes Through 2a081b9There are 1 changes which include wry with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
Legend-Master
previously approved these changes
May 26, 2026
Contributor
Legend-Master
left a comment
There was a problem hiding this comment.
Thanks! Could you also add a change file?
Also you'll need to sign your commits for me to merge this
78b1836 to
44239c3
Compare
…port Adds `WebViewBuilderExtWindows::with_profile_name(name)` so embedded webviews can opt into a named WebView2 profile. Webviews with different profile names within the same environment have isolated cookies, storage, IndexedDB, and cache while sharing the runtime — matching WebView2's documented multi-profile pattern. When unset, behavior is unchanged (unnamed default profile). Implementation: - New `profile_name: Option<String>` field on the Windows `PlatformSpecificWebViewAttributes`. - New trait method on `WebViewBuilderExtWindows`. - In `create_controller`, when a profile name is configured, call `ICoreWebView2ControllerOptions::SetProfileName` before `CreateCoreWebView2ControllerWithOptions`. Profile names must follow WebView2's naming rules (alphanumeric, `.`, `_`, `-`, ` `, up to 64 chars, not starting/ending with `.` or ` `). See https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/multi-profile-support
44239c3 to
2a081b9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
WebViewBuilderExtWindows::with_profile_nameso embedded webviews can opt into a named WebView2 profile, isolating cookies, storage, IndexedDB, and cache from the host app's default profile while sharing the same WebView2 environment/runtime.Motivation
A common use case for
wry(and Tauri downstream) is hosting an in-app browser tab alongside the main app webview. Without profile isolation, both share the unnamed default profile under the sameuser_data_folder, which means anything a user does in the embedded browser (signing into github.com, storing cookies, etc.) is mixed with the host app's ownlocalStoragestate. Profile-wide operations like clearing browsing data become unsafe because they touch the host app's storage as collateral damage.with_data_directory(separateuser_data_folder) is the existing workaround but it creates an entirely separate WebView2 environment with its own runtime/networking stack — which has historically caused OAuth/login-page regressions in apps that tried it (downstream report: Glint #2665).Microsoft's recommended multi-profile pattern (https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/multi-profile-support) is named profiles within a shared environment, which
ICoreWebView2ControllerOptions::SetProfileNameenables. This PR exposes it through wry.Changes
profile_name: Option<String>field on the WindowsPlatformSpecificWebViewAttributes.WebViewBuilderExtWindows:with_profile_name<S: Into<String>>(self, name: S) -> Self.create_controller, when a profile name is configured, callICoreWebView2ControllerOptions::SetProfileNamebeforeCreateCoreWebView2ControllerWithOptions.When
with_profile_nameis not called the behavior is unchanged — the webview uses the unnamed default profile, same as today.Platform notes
This PR only touches Windows. macOS / iOS already have
with_data_store_identifierfor the equivalent functionality. A follow-up could add the Linux equivalent (a dedicatedWebsiteDataManagerdirectory) under a unified API name if there's appetite for that.Naming-rule notes
WebView2 enforces profile-name rules (alphanumeric +
.,_,-, space; up to 64 chars; cannot start or end with.or space). The doc-comment onwith_profile_namementions these constraints. The patch doesn't validate the string client-side —SetProfileNamereturns an error for malformed names, which is surfaced as awry::Errorat build time.Related