Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: WebView2: Initialization failed due to incompatible environment configurations. #4174

Open
btlopener opened this issue Nov 16, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@btlopener
Copy link

btlopener commented Nov 16, 2023

What happened?

Hi,

I'm currently facing an issue where I consistently specify the same options for my environment configuration. However, in a few rare cases , I encounter the following error in my output window:
WebView2: Initialization failed due to incompatible environment configurations. Please check if there is already a WebView2 running with the same user data folder but different environment parameters.

In CreateCoreWebView2Controller handler I get the error code ERROR_INVALID_STATE:
"The group or resource is not in the correct state to perform the requested operation. (0x8007139f)"

I'm unsure why this inconsistency is happening despite consistently specifying the same options. If I use one profile folder for each webview, everything works (for my scenario at least)

Edit:
I also try:
to alternate between two profile folders, and everything works.
to put a Sleep(50) before CreateCoreWebView2Controller If the time elapsed since the last call to CreateCoreWebView2Controller (for all WebView) is less than 50 ms, and everything works. 50 ms is arbitrary.

Could you provide guidance on how to identify and resolve this issue?

Thank you.

Importance

Moderate. My app's user experience is affected, but still usable.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

119.0.2151.44

SDK Version

1.0.2151.40

Framework

Win32

Operating System

Windows 10

OS Version

19044.2075

Repro steps

It will be hard to give exact repros steps, here my setup

  • Fixed version
  • Multiple WebView creation/deletion (7)
  • Using the same folder and identical options (to the best of my knowledge)

Regression

Don't know

Last working version (if regression)

No response

@btlopener btlopener added the bug Something isn't working label Nov 16, 2023
@victorhuangwq victorhuangwq assigned srwei and lflores-ms and unassigned srwei Nov 17, 2023
@btlopener
Copy link
Author

I discovered another scenario in our automated tests where the problem occurs. I may be able to work around it in my code. Here are the steps; the exact reproduction steps/conditions are hard to specify.

  1. No WebView profile folder
  2. Creation of a WebView (implies the creation of the folder)
  3. Rapid deletion (automated click on the dialog with the WebView):
  4. Creation of a new WebView (the error occurs, not consistently):

@btlopener btlopener reopened this Nov 20, 2023
@mpecikiewicz
Copy link

mpecikiewicz commented Jun 24, 2024

Hi,
we seem to have similar issues, however the configuration is a little bit different:

Runtime Channel
Evergreen Bootstrapper
Runtime Version
126.0.2592.61
SDK Version
1.0.2478.35
Framework
Win32 - Microsoft.Web.WebView2.WinForms
Operating System
Windows Server 2019
OS Version
1809 (Build 17763.5830)

We do get the same exception (from CreateCoreWebView2Controller) inside the app:
The group or resource is not in the correct state to perform the requested operation. (Exception from HRESULT: 0x8007139F)

After adding WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS (--enable-logging --v=1 --log-file=c:\temp\webview2.log) for better logging, we were able to get more specific information about the issue:

> [0621/105722.443:ERROR:connection_impl.cc(145)] Incompatible WebView configuration, current command line:
> "C:\Program Files (x86)\Microsoft\EdgeWebView\Application\126.0.2592.61\msedgewebview2.exe" --embedded-browser-webview=1 --webview-exe-name="Our_app.exe" --webview-exe-version=2024.2.0.3367 --user-data-dir="C:\Users\u.name\AppData\Local\WebView2Browser\EBWebView" --noerrdialogs --embedded-browser-webview-dpi-awareness=1 --enable-features=MojoIpcz --enable-logging --log-file="c:\temp\webview2.log" --v=1 --mojo-named-platform-channel-pipe=1848.11852.3202395723509272077 --flag-switches-begin --flag-switches-end --no-default-browser-check --disable-component-extensions-with-background-pages --no-first-run --disable-default-apps --internet-explorer-integration=none --js-flags="--harmony-weak-refs-with-cleanup-some --expose-gc" --disable-popup-blocking --disable-sync --sdsm-state=offincoming command line:
> "C:\Program Files (x86)\Microsoft\EdgeWebView\Application\126.0.2592.61\msedgewebview2.exe" --embedded-browser-webview=1 --webview-exe-name="Our_app.exe" --webview-exe-version=2024.2.0.3367 --user-data-dir="C:\Users\u.name\AppData\Local\WebView2Browser\EBWebView" --noerrdialogs --embedded-browser-webview-dpi-awareness=1 --enable-features=MojoIpcz --enable-logging --log-file="c:\temp\webview2.log" --v=1 --mojo-named-platform-channel-pipe=14548.12204.12460200557896422689
> [0621/105724.154:ERROR:edge_auth_errors.cc(520)] EDGE_IDENTITY: Get Default OS Account failed: Error: Primary Error: kTokenRequestFailed, Secondary Error: kTokenFetchUserInteractionRequired, Platform error: -895352820, hex:caa2000c, Error string: Error code: 0xcaa2000c, error message:AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access 'f2d19332-a09d-48c8-a53b-c49ae5502dfc'. Trace ID: 512fa6d2-3e10-40b9-a461-44f697c12b00 Correlation ID: 303ce651-c641-4570-8494-4956d4f66acc Timestamp: 2024-06-21 08:57:23Z

At first it seemed to be quite random, but now we are pretty sure it's happening straight after Evergreen Bootstrapper updates runtime to newer version. If we run our app for the first time, it will crash with this exception. Subsequent runs are fine, up till next runtime update, so it seems the runtime fixes configuration.

So the key in our case is auto update causing incompatible configuration.

Are there any chances of avoiding this exception?
We are thinking about catching and killing this exception, but 0x8007139F error could mean a lot of different things.

One more important thing:

  • we use custom UserDataFolder set in CoreWebView2CreationProperties

@mpecikiewicz
Copy link

We've switched from very old fixed runtime version 91, to Evergreen. It seems the whole issue is about Evergreen updates vs. old version configuration in UserDataFolder.

There is a NewBrowserVersionAvailable event, but it only fires when the app is running old version and new appears on the machine.

We still need some guideline on how to handle "Incompatible WebView configuration" errors.

@mpecikiewicz
Copy link

Hi,
@lflores-ms, any chance we could get any feedback on this? Any guideline on how to handle runtime automatic updates that result in UserDataFolder config errors would be much appreciated.

The issue happens for us on regular basis. We tried to do everyting to get WebView2 to reinitialize, but no luck. Only the restart of the whole app helps, but this gives terrible user experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants