You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to apply browser arguments to preview auto-play behavior for media elements in the browser using the --disable-features startup flag.
I'm using the code like the following:
// must create a data folder if running out of a secured folder that can't write like Program FilesvarbrowserFolder= Path.Combine(mmApp.Configuration.InternalCommonFolder, mmApp.Constants.WebViewEnvironmentFolderName);varenv=await CoreWebView2Environment.CreateAsync(
userDataFolder: browserFolder, options:new CoreWebView2EnvironmentOptions
{AdditionalBrowserArguments="--disable-features=\"PreloadMediaEngagementData, MediaEngagementBypassAutoplayPolicies\"",});await WebBrowser.EnsureCoreWebView2Async(env);
When I use this (or several other startup flags I've tried, my WebView control fails to initialize and I get a blank WebView canvas - the browser appears to not load. I also don't get an error or a trigger in the BrowserProcessFailed event.
I'm not sure whether I'm using the Arguments option correctly and haven't been able to dig up any examples.
Expected behavior
Should work 😄
If it fails should throw or have some indiciation on what failed
WebView Control WPF (1.0.1901.177
.NET 7.0
Windows 11
The text was updated successfully, but these errors were encountered:
If I had to guess based off what you've shared - Do you have a WebView2 already created with that userDataFolder, but with different AdditionalBrowserArguments?
That's likely the problem, you'd see an initialization error of 0x8007139F (ERROR_INVALID_STATE) if that's the case. The table at the bottom of the docs for EnsureCoreWebView2Async mentions it.
As far as processes - Each WV2 creates a new renderer process, each UserDataFolder (UDF) creates a new browser process and AdditionalBrowserArguments essentially sets global state for the browser process. Every WV2 created with that UDF needs to have the same EnvironmentOptions / CreationProperties or it will fail. We chose to fail in this case since the AdditionalBrowserArguments can't/won't be respected due to the process already existing.
There is confusion around it sometimes and it's not perfect for every use-case - For your use-case, what would your preferred behavior be if we can't respect your EnvironmentOptions due to a conflict with existing processes? Some suggestions we've seen in the past include a setting to ignore the options if they differ, automatical create a new UDF (#3668), or somehow attempt to restart all the WV2s for the UDF.
I'm trying to apply browser arguments to preview auto-play behavior for media elements in the browser using the
--disable-features
startup flag.I'm using the code like the following:
When I use this (or several other startup flags I've tried, my WebView control fails to initialize and I get a blank WebView canvas - the browser appears to not load. I also don't get an error or a trigger in the BrowserProcessFailed event.
I'm not sure whether I'm using the Arguments option correctly and haven't been able to dig up any examples.
Expected behavior
Should work 😄
If it fails should throw or have some indiciation on what failed
WebView Control WPF (1.0.1901.177
.NET 7.0
Windows 11
The text was updated successfully, but these errors were encountered: