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

COMException 0x8007139F in Microsoft.Web.WebView2.WinForms.WebView2.<InitCoreWebView2Async>d__13.MoveNext #3008

Closed
ShaunLoganOracle opened this issue Nov 29, 2022 · 83 comments
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@ShaunLoganOracle
Copy link

ShaunLoganOracle commented Nov 29, 2022

Description
We have some customers that are encountering this exception when our code is creating a WebView2 control hosted in a Winform. The UserDataFolder used is specific to the user and not shared by other apps. We use the same CoreWebView2Environment properties when calling EnsureCoreWebView2() for subsequent WV2 controls we create. We are unable to reproduce the issue in-house.

COMException: The group or resource is not in the correct state to perform the requested operation. (Exception from HRESULT: 0x8007139F)
Source: mscorlib
Stack: 
  at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
  at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
  at Microsoft.Web.WebView2.Core.CoreWebView2Environment.<CreateCoreWebView2ControllerAsync>d__41.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  at Microsoft.Web.WebView2.WinForms.WebView2.<InitCoreWebView2Async>d__13.MoveNext()

Version
SDK: 1.0.1343.22
Runtime: 107.0.1418.52
Framework: WinForms
OS: Win10, exact version info not yet if available
VSTO Add-in running in Excel

Repro Steps
Our code does in essence, the following.

In our Winform that hosts the WV2 control:

      private void HandleFormLoaded (object sender, EventArgs e)
      {
            await WebView2Control.InitializeWebView2Async (); // WebView2Control is an instance of our subclass of WebView2
            // once init is complete, we navigate to a URL in the WV2
      }

In our subclass of Microsoft.Web.WebView2.WinForms.WebView2:

      public async Task InitializeWebView2Async ()
      {
         CoreWebView2EnvironmentOptions options = new CoreWebView2EnvironmentOptions ()
         {
            AdditionalBrowserArguments = // <snip> nothing interesting
            Language = // something appropriate,
            AllowSingleSignOnUsingOSPrimaryAccount = true,
         };

         string userDataFolder = // something that resolves to %LocalAppData%\MyCompany\Our Addin Name\
         CoreWebView2Environment webView2Environment = await CoreWebView2Environment.CreateAsync (null, userDataFolder, options);

         await EnsureCoreWebView2Async (webView2Environment); // this is the base class impl: WebView2.EnsureCoreWebView2Async
      }

In our event handler for CoreWebView2InitializationCompleted, we get e.IsSuccess = false with e.InitializationException as shown in the stack above.

Additional context
We saw this GH issue: #2495, which might be related, but the exception stacks there are WPF so they don't match ours exactly..
We have multiple customers at different companies encountering this issue. We also have many customers across companies not encountering this issue.

Diagnostics
We are unable to use a debugger at the customer sites.
How can we capture additional logs from the customer to help us diagnose the root cause of the exception?

AB#43230947

@ShaunLoganOracle ShaunLoganOracle added the bug Something isn't working label Nov 29, 2022
@ShaunLoganOracle
Copy link
Author

ShaunLoganOracle commented Nov 29, 2022

Additional Info: We have one customer that reports getting this exception when they:

  1. Using the Google Chrome browser, click on a web page link that downloads an XLSX file
  2. Open the XLSX file as part of the download operation
  3. When Excel opens the file, our add-in is notified and we put up the Winform with the WebView2 control and get the exception: COMException 0x8007139F in Microsoft.Web.WebView2.WinForms.WebView2.d__13.MoveNext

Note! according to the customer, the exception is not seen if they follow these same steps using Firefox, MSIE, and Edge to download + open the XLSX file.

@ShaunLoganOracle
Copy link
Author

@yunate
In case it helps, here is a slightly different exception stack from a different customer:

COMException: The group or resource is not in the correct state to perform the requested operation. (Exception from HRESULT: 0x8007139F)
Source: mscorlib
Stack: 
  at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
  at Microsoft.Web.WebView2.Core.CoreWebView2Environment.<CreateCoreWebView2ControllerAsync>d__80.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
  at Microsoft.Web.WebView2.WinForms.WebView2.<InitCoreWebView2Async>d__23.MoveNext()

@ShaunLoganOracle
Copy link
Author

@yunate
re: specific Windows OS versions. Both of the customers mentioned are on Windows 10.
The first exception stack is from Windows 10 20H2 (19042.2251), using WV2 RT 107.0.1418.62
The second exception stack is from Windows 10 21H2 (19044.2006), also using WV2 RT 107.0.1418.62

I was able to get a the first customer to capture a verbose log from WebView2 by setting:
Env. Var.: WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS = --enable-logging --v=1 --log-file=c:\temp\webview2.log

I am looking through this log now, is there anything specific I can search for to get closer to what's causing this COMException?

@ShaunLoganOracle
Copy link
Author

Here is the tail end of the customer's log (before the histograms) showing 3 ERRORs (I redacted some information and added blank lines). I know virtually nothing about the internals of Chrome. Are these ERRORs significant/related to the COMException? I don't see errors like these when I run WV2 locally.

[12556:16216:1202/165413.237:ERROR:device_event_log_impl.cc(215)] [16:54:13.237] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[12556:16216:1202/165413.241:VERBOSE1:device_event_log_impl.cc(217)] [16:54:13.242] USB: USER: usb_service_win.cc:739 USB device added: path=\\?\usb#vid_04f2&pid_b51c#[REDACTED] vendor=1266 "", product=46364 "", serial="", driver="usbccgp", guid=[REDACTED]

[12556:9728:1202/165413.491:ERROR:util.cc(135)] Can't create base directory: C:\Program Files\Microsoft\EdgeUpdater
[12556:16216:1202/165413.503:VERBOSE1:request_sender.cc(143)] is off the record0
[13896:14660:1202/165413.504:VERBOSE1:network_delegate.cc(34)] NetworkDelegate::NotifyBeforeURLRequest: https://edge.microsoft.com/componentupdater/api/v1/update?cup2key=5:GUtE[REDACTED]
[12556:16216:1202/165413.758:VERBOSE1:request_sender.cc(218)] Request completed from url: https://edge.microsoft.com/componentupdater/api/v1/update?cup2key=5:GUtE[REDACTED]
[12556:16216:1202/165413.760:VERBOSE1:component_updater_service.cc(439)] Update completed with error 0
[12556:16216:1202/165416.141:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Stats.LogStart [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165416.143:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.SystemProfile [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165416.143:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Histograms.Default [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165416.143:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Histograms.Group4 [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165416.143:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Stats.LogComplete [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165419.150:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Stats.LogStart [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165419.150:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.SystemProfile [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165419.150:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Histograms.Default [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165419.151:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Histograms.Group4 [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165419.151:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Stats.LogComplete [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165422.160:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Stats.LogStart [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165422.160:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.SystemProfile [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165422.161:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Histograms.Group4 [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165422.162:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Histograms.Default [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165422.162:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Histograms.Group2 [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165422.162:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Stats.LogComplete [components\telemetry_client\telemetry_service.cc(207)]

[9444:15496:1202/165513.308:ERROR:gpu_init.cc(551)] Passthrough is not supported, GL is disabled, ANGLE is 
[12556:16216:1202/165526.143:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Stats.LogStart [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165526.143:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.SystemProfile [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165526.144:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Histograms.Group4 [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165526.144:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Histograms.Default [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165526.144:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Histograms.Group2 [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165526.144:VERBOSE1:telemetry_service.cc(626)] NotInSampleGroup: Microsoft.WebBrowser.Protobuf.UMA.Stats.LogComplete [components\telemetry_client\telemetry_service.cc(207)]
[12556:16216:1202/165526.148:VERBOSE1:sync_session_durations_metrics_recorder.cc(95)] Session end
[12556:16216:1202/165526.149:VERBOSE1:account_reconcilor.cc(225)] AccountReconcilor::Shutdown
[12556:16216:1202/165526.149:VERBOSE1:account_reconcilor.cc(659)] AccountReconcilor::AbortReconcile: try again later
[12556:16216:1202/165526.149:VERBOSE1:account_reconcilor.cc(756)] AccountReconcilor::CalculateIfMultiloginReconcileIsDone: Error was 
[12556:16216:1202/165526.149:VERBOSE1:account_reconcilor.cc(268)] AccountReconcilor::UnregisterWithIdentityManager
[12556:16216:1202/165526.149:VERBOSE1:account_reconcilor.cc(247)] AccountReconcilor::UnregisterWithContentSettings
[12556:16216:1202/165526.149:VERBOSE1:gaia_cookie_manager_service.cc(707)] GaiaCookieManagerService::CancelAll
[12556:16216:1202/165526.149:VERBOSE1:mutable_profile_oauth2_token_service_delegate.cc(822)] MutablePO2TS::Shutdown
[12556:16216:1202/165526.149:VERBOSE1:mutable_profile_oauth2_token_service_delegate.cc(321)] MutablePO2TS::~MutablePO2TS
[12556:16216:1202/165526.149:VERBOSE1:device_event_log_impl.cc(217)] [16:55:26.149] Bluetooth: EVENT: bluetooth_api.cc:109 BluetoothAPI: Shutdown
[12556:16216:1202/165526.153:VERBOSE1:account_reconcilor.cc(168)] AccountReconcilor::~AccountReconcilor
[12556:16216:1202/165526.153:VERBOSE1:device_event_log_impl.cc(217)] [16:55:26.153] Bluetooth: EVENT: bluetooth_api.cc:95 ~BluetoothAPI: 00003B7000298600
[13896:14940:1202/165526.171:VERBOSE1:statistics_recorder.cc(520)] Collections of all histograms

@AlexDavisOracle
Copy link

@yunate are you looking at this issue actively? It is a hot topic for us.
Please review the posts from Shaun above and provide some update. Thanks!

@AlexDavisOracle
Copy link

@nishitha-burman Hi! This topic is pretty hot for us currently. Would it be possible to get someone to look at it? Thanks!

@ShaunLoganOracle
Copy link
Author

I received a WebView2 log from another customer (also via by Env. Var.: WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS = --enable-logging --v=1 --log-file=c:\temp\webview2.log). In this case the only error in the log is:

[9016:19016:1212/144338.629:ERROR:edge_auth_errors.cc(477)] EDGE_IDENTITY: Get Default OS Account failed: Error: Primary Error: kImplicitSignInFailure, Secondary Error: kAccountProviderFetchError, Platform error: 0, Error string: 

However I see the same error when I run the add-in w/WebView2 locally - and the COMException 0x8007139F does not repro for me. Since we are not able to run a debugger at the customer sites where this issue occurs, is there some additional logging or diagnostic information we can capture to help us find what is causing this exception?

@AlexDavisOracle
Copy link

@champnic would you be able to help with this issue? Thanks!

@ShaunLoganOracle
Copy link
Author

ShaunLoganOracle commented Dec 27, 2022

For anyone else following this issue, I stumbled upon this reference to getting WV2-specific events logged in the Event Viewer: link

@yunate
Copy link
Contributor

yunate commented Dec 28, 2022

@ShaunLoganOracle, I'm sorry I haven't had one for so long, and I will look into this issue.

@yunate
Copy link
Contributor

yunate commented Dec 28, 2022

@ShaunLoganOracle Is it possible to take a perf trace for this? The instruction on how to take a trace is at microsoft/microsoft-ui-xaml#5816 (comment). The trace file will be a large file that has to be shared via some cloud drive.

Or use DebugView(https://learn.microsoft.com/en-us/sysinternals/downloads/debugview) to find the log like WebView2: Initialization failed.
image

@ShaunLoganOracle
Copy link
Author

@yunate
Thanks for the reply. I notice that two different WPRP files have been suggested:

  1. EdgeWebView2_CPU.wprp from here
  2. WebView2.wprp from here
    Which one is best for this case?

@ShaunLoganOracle
Copy link
Author

Capturing WV2-specific events seems like it would be helpful. Unfortunately, we are blocked from using the Windows Performance Recorder because:

  1. We (and our customers) are using Windows 10. After installing the appropriate WPR from here, we are unable to successful capture a recording file. We get (on the wpr -stop command):
        Cannot change thread mode after it is set.
        Profile Id: RunningProfile
        Error code: 0x80010106
  1. This MS blog post indicates that the way around this error is to install a later build of the WPR ("build 19650 or later"), from the Insider Channel. Our customers may not be Windows Insiders, so this is not a viable approach.

For others reading this, Admin/elevated privileges are required to install/run the WPR. This may not be feasible in all cases.

Is there another mechanism for getting a newer Windows ADK for Windows 10 (with the WPR) that will successfully record a trace file?

@yunate
Copy link
Contributor

yunate commented Dec 29, 2022

Capturing WV2-specific events seems like it would be helpful. Unfortunately, we are blocked from using the Windows Performance Recorder because:

  1. We (and our customers) are using Windows 10. After installing the appropriate WPR from here, we are unable to successful capture a recording file. We get (on the wpr -stop command):
        Cannot change thread mode after it is set.
        Profile Id: RunningProfile
        Error code: 0x80010106
  1. This MS blog post indicates that the way around this error is to install a later build of the WPR ("build 19650 or later"), from the Insider Channel. Our customers may not be Windows Insiders, so this is not a viable approach.

For others reading this, Admin/elevated privileges are required to install/run the WPR. This may not be feasible in all cases.

Is there another mechanism for getting a newer Windows ADK for Windows 10 (with the WPR) that will successfully record a trace file?

For this issue, we could use DebugView(https://learn.microsoft.com/en-us/sysinternals/downloads/debugview) to find the log like WebView2: Initialization failed.
image

@ShaunLoganOracle
Copy link
Author

@yunate Thank you. I want to give the customer who can reproduce the issue the correct instructions, can you please confirm whether or not the default Capture settings for DebugView are sufficient to capture the WebView2 output?
image

@yunate
Copy link
Contributor

yunate commented Jan 3, 2023

Fortunately, we have logged by OutputDebugString function specially for except 0x8007139F, so we can use DebugView to capture the WebView2 output and use default Capture settings is okay.

@ShaunLoganOracle
Copy link
Author

ShaunLoganOracle commented Jan 6, 2023

@yunate We received a DebugView log from one of the customers. It contains:

00002219	46.17500305	[3040] RecursiveDirectoryCreate( C:\Users\<USER>\AppData\Local\Oracle\ADF Desktop Integration\EBWebView directory exists )	
00002220	46.68103027	[18140] WebView2: Initialization failed due to a mismatch in DPI awareness. Please ensure that the DPI awareness of the host app matches the DPI awareness of current WebView2 processes using the same user data folder.

In our case, we are a VSTO add-in running inside of the Excel.exe process. We don't control the DPI awareness of the host app, and we're getting this exception with a single WebView2 process associated with the UDF (unlike #899 where there are two apps w/different DPI awareness sharing the UDF).

Since we re-use the UDF for different excel.exe sessions, could this exception be caused by the user running Excel (and WV2) on one set of display settings, then running Excel again with different settings (but sharing the same UDF)?
Are there other causes that would explain this debug log message?

@ShaunLoganOracle
Copy link
Author

@yunate We got another DebugView log from another customer, it shows the same "... mismatch in DPI awareness..." issue.
What could be the cause of this error in our case?

@yunate
Copy link
Contributor

yunate commented Jan 11, 2023

@yunate We received a DebugView log from one of the customers. It contains:

00002219	46.17500305	[3040] RecursiveDirectoryCreate( C:\Users\<USER>\AppData\Local\Oracle\ADF Desktop Integration\EBWebView directory exists )	
00002220	46.68103027	[18140] WebView2: Initialization failed due to a mismatch in DPI awareness. Please ensure that the DPI awareness of the host app matches the DPI awareness of current WebView2 processes using the same user data folder.

In our case, we are a VSTO add-in running inside of the Excel.exe process. We don't control the DPI awareness of the host app, and we're getting this exception with a single WebView2 process associated with the UDF (unlike #899 where there are two apps w/different DPI awareness sharing the UDF).

Since we re-use the UDF for different excel.exe sessions, could this exception be caused by the user running Excel (and WV2) on one set of display settings, then running Excel again with different settings (but sharing the same UDF)? Are there other causes that would explain this debug log message?

Thanks for your reply, and I'm the reason of DPI issue, and I will inform you of any progress

@yunate
Copy link
Contributor

yunate commented Jan 11, 2023

This is a bug and will be fix in next release (release-109), and this will be published soon.

@AlexDavisOracle
Copy link

@yunate Great news! Thanks for the update! Will it be fixed in the WebView2 runtime or SDK?

@yunate
Copy link
Contributor

yunate commented Jan 11, 2023

@yunate Great news! Thanks for the update! Will it be fixed in the WebView2 runtime or SDK?

Yes, both runtime and SDK will be all updates. And should be published next week.

@AlexDavisOracle
Copy link

Does the fix for this particular issue require an SDK upgrade?
Or, will our joint customers get the fix automatically when the evergreen runtime updates to 109?
@yunate

@yunate
Copy link
Contributor

yunate commented Jan 11, 2023

It requires an SDK upgrade to make the app can use the 109 runtime.

@AlexDavisOracle
Copy link

AlexDavisOracle commented Jan 11, 2023

Thanks for the quick responses, @yunate . But, I am a little confused...

It requires an SDK upgrade to make the app can use the 109 runtime.

Generally, the latest WebView2 runtime is used without any SDK upgrade in the host application...

@yunate
Copy link
Contributor

yunate commented Jan 11, 2023

The SDK version should match the runtime. The SDK file: Microsoft.Web.WebView2.Wpf.dll/Microsoft.Web.WebView2.Core.dll/WebView2Loader.dll should be upgraded. If you do not upgrade the SDK, the runtime you used may be the old one.

@ShaunLoganOracle
Copy link
Author

@yunate
It is great news that the fix has been identified! In the meantime, is there any action we can have our customers take to avoid/workaround this issue (until they get the fix)?

@ShaunLoganOracle
Copy link
Author

@yunate
One of customers that is getting the COMException 0x8007139F upgraded to WV2 Runtime 109.0.1518.52, deleted their UDF, and was still able to reproduce the issue. We have diagnostic logging that confirms the version of the WV2 RT in use when they reproduced the issue.
Is this fix in the WV2 Runtime or the WV2 SDK?

@ShaunLoganOracle
Copy link
Author

Hi @LiangTheDev
It has been a while and we still have customers encountering this issue (and asking us for updates about a fix). Is there anything I can pass along to them?
Thanks.

@LiangTheDev
Copy link
Member

@ShaunLoganOracle unfortunately there is no meaningful progress made on this. I've made the issue more visible and hopefully we could make some progress in the near future.

@G-Equipment
Copy link

G-Equipment commented Apr 28, 2023

Hello,

I have the same probleme here, nothing special in the regedit.
Here is the base error :
UNHANDLED EXCEPTION IN MAIN APPLICATION THREAD: [COMException]: "Opération abandonnée (Exception from HRESULT: 0x80004004 (E_ABORT))" at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at Microsoft.Web.WebView2.Core.CoreWebView2Environment.<CreateCoreWebView2ControllerAsync>d__88.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Web.WebView2.WinForms.WebView2.<InitCoreWebView2Async>d__26.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at IHM_v8.WebBrowser.<PdfV_Load>d__16.MoveNext() in C:\dev\IHM_v8\IHM_v8\WebBrowser.cs:line 118 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

Here is the log from WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS :

[14088:12960:0428/171541.219:WARNING:chrome_main_delegate.cc(653)] This is Chrome version 112.0.1722.58 (not a warning) [14088:12960:0428/171541.285:WARNING:chrome_browser_cloud_management_controller.cc(87)] Could not create policy manager as CBCM is not enabled. [14088:12960:0428/171541.288:VERBOSE1:variations_field_trial_creator.cc(88)] VariationsSeedUsage:2 [14088:12960:0428/171541.288:VERBOSE1:variations_field_trial_creator.cc(443)] VariationsSetupComplete [14088:12960:0428/171541.300:ERROR:win_util.cc(1496)] failed to set WebView dpi awareness of 1: L’opération a réussi. (0x0) [14088:12960:0428/171541.329:VERBOSE1:webrtc_event_log_manager.cc(97)] WebRTC remote-bound event logging enabled. [14088:12960:0428/171541.330:VERBOSE1:pref_proxy_config_tracker_impl.cc(187)] 00003EE0022EC900: set chrome proxy config service to 00003EE0022C8540 [14088:8888:0428/171541.351:VERBOSE1:media_stream_manager.cc(1596)] MSM::InitializeMaybeAsync([this=00003EE002286100]) [14088:8888:0428/171541.351:VERBOSE1:media_stream_manager.cc(1596)] MDM::MediaDevicesManager() [14088:8888:0428/171541.351:VERBOSE1:media_stream_manager.cc(1596)] MSM::MediaStreamManager([this=00003EE002286100])) [14088:20612:0428/171541.353:VERBOSE1:chrome_browser_main.cc(779)] TryInitWindowTabManager start [14088:20612:0428/171541.353:VERBOSE1:wtm_interface_factory.cc(85)] WTM is not used for WebView. [14088:12960:0428/171541.355:ERROR:chrome_browser_cloud_management_controller.cc(162)] Cloud management controller initialization aborted as CBCM is not enabled.
Everything was working perfectly yesterday.

@ShaunLoganOracle
Copy link
Author

@G-Equipment Are you sure that you're seeing the same issue? I reported COMException 0x8007139F. You're seeing 0x80004004 (E_ABORT). If you search for E_ABORT in this form ( is:issue E_ABORT ) you'll see other issues with that error code from Winforms.

@G-Equipment
Copy link

@G-Equipment Are you sure that you're seeing the same issue? I reported COMException 0x8007139F. You're seeing 0x80004004 (E_ABORT). If you search for E_ABORT in this form ( is:issue E_ABORT ) you'll see other issues with that error code from Winforms.

I think you're right. Sorry

@xiakan
Copy link

xiakan commented May 29, 2023

@ShaunLoganOracle I have also encountered the same problem as you. Have you resolved this issue?

@ShaunLoganOracle
Copy link
Author

@ShaunLoganOracle I have also encountered the same problem as you. Have you resolved this issue?

@xiakan
No, please see @LiangTheDev 's reply from April 10 in this thread

@xiakan
Copy link

xiakan commented May 30, 2023

@ShaunLoganOracle
This problem has occurred frequently in the past few days, Microsoft.UI.Xaml.Controls.Webview2 with 1.0.1661.34, which has been replicated on my machine just now.

@xiakan
Copy link

xiakan commented May 30, 2023

Restarting the computer suddenly throws an exception, and the usual recovery method is to restart the computer again

@LiangTheDev
Copy link
Member

@xiakan it is the same issue and that issue is not resolved if you see this debug message when attaching the debugger to the application process: "WebView2: Initialization failed due to a mismatch in DPI awareness.".
It is related to app compat layer applied to msedgewebview2.exe, the application exe or some ancestor process of the application process. For this issue, we currently don't have a solution. Not sure why restarting the computer would change app compat settings. So, please first make sure that it is the same issue.

@ShaunLoganOracle
Copy link
Author

April 10:
@ShaunLoganOracle unfortunately there is no meaningful progress made on this. I've made the issue more visible and hopefully we could make some progress in the near future.

@LiangTheDev some of our joint (Microsoft & Oracle) customers are inquiring about progress on this issue. Is there anything I can share with them?

@LiangTheDev
Copy link
Member

All I can say is that we are still investigating it and it is not something that we can fix in Edge WebView2 code alone.

@LevchenkoOleksandr
Copy link

I also have the same issue on my dev machine: (The group or resource is not in the correct state to perform the requested operation)
I have Outlook COM add-in hosing WebView2 (Win32/WPF)
Latest runtime 114.0.1823.82
Have similar issue on DebugView:
WebView2: Initialization failed due to a mismatch in DPI awareness. Please ensure that the DPI awareness of the host app matches the DPI awareness of current WebView2 processes using the same user data folder
No compatibility overrides for Outlook.

Ready to cooperate for solving the issue since I have dev machine with all possible access and permissions

@LiangTheDev
Copy link
Member

We just made a change for the dpi awareness issue. Could you please try it out with Edge Canary and see whether the fix works? The change is in Edge version >= 117.0.2007.0, which means available in latest Edge Canary only currently.

@LevchenkoOleksandr
Copy link

Hello support team. Unfortunately it didn't fix in my case.
I have downloaded Canary Edge version 117.0.2007.0 and tried to initialize my webview2 with direct path:
result = await CoreWebView2Environment.CreateAsync("C:\Users[my_user_name]\AppData\Local\Microsoft\Edge SxS\Application\117.0.2007.0", ...

Ensured loaded version result.BrowserVersionString is 117.0.2007.0 canary
And got same warning: WebView2: Initialization failed due to a mismatch in DPI awareness. Please ensure that the DPI awareness of the host app matches the DPI awareness of current WebView2 processes using the same user data folder.

As the result I have initial error:
The group or resource is not in the correct state to perform the requested operation. (Exception from HRESULT: 0x8007139F

@LiangTheDev
Copy link
Member

LiangTheDev commented Jul 27, 2023

@LevchenkoOleksandr is there anything in registry HKLM or HKCU under Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers?

@LevchenkoOleksandr
Copy link

No, I didn't set any compatibility overrides

@LiangTheDev
Copy link
Member

@LevchenkoOleksandr then it is not the same issue discussed in this thread and the fix is trying to fix. Could you please take an ETW trace of the repro? Instruction for taking ETW trace is at https://github.com/MicrosoftEdge/WebView2Feedback/blob/main/diagnostics/etw.md, using https://github.com/MicrosoftEdge/WebView2Feedback/blob/main/diagnostics/WebView2.wprp should be good enough. You can share the trace privately with me at lzhao@microsoft.com.

@ShaunLoganOracle
Copy link
Author

@LiangTheDev , you said:

We just made a change for the dpi awareness issue. Could you please try it out with Edge Canary and see whether the fix works? The change is in Edge version >= 117.0.2007.0, which means available in latest Edge Canary only currently.

I reproduced the issue using the simple use case of changing High DPI scaling on Excel.exe to "System (Enhanced)", using WV2 RT 115.0.1901.188. Then I uninstalled that WV2 RT and installed the Edge Canary (117.0.2017.0 canary).
Good news: when I tried my simple case, the issue did not reproduce. So, I am hopeful that once the 117.0.xxx WebView2 Runtime gets pushed out to customers, they will no longer encounter this issue.

@ShaunLoganOracle
Copy link
Author

Since we have customers waiting for this fix, is there anything you can say about the timeline for it appearing (even roughly)?

@LiangTheDev
Copy link
Member

@ShaunLoganOracle thanks for testing it and great to hear that the change seems to make a difference. Edge 117 should be released around Week of 14-Sep-2023.

And in offline discussion, it is found that the issue @LevchenkoOleksandr encountered is likely due to multiple apps sharing the same user data folder.

@LevchenkoOleksandr
Copy link

And in offline discussion, it is found that the issue @LevchenkoOleksandr encountered is likely due to multiple apps sharing the same user data folder.

Thank you for your help and pointing me to correct direction. In my case it really was sharing the same folder between components.

@champnic champnic closed this as completed Aug 3, 2023
@ShaunLoganOracle
Copy link
Author

Edge 117 should be released around Week of 14-Sep-2023

I look forward to trying out the fix soon.
For the record, the issue still repros with SDK 1.0.1938.49 and RT 116.0.1938.76

@LiangTheDev
Copy link
Member

As with all software development, release schedule is often delayed. From information I have gathered, it looks like Edge 117 is likely to be released sometime next week.

@sln162
Copy link

sln162 commented Sep 12, 2023

@ShaunLoganOracle According to my observation, every time there is a major version update (such as 117), WebView2 can download to 117, and the bootstrapper can also install to 117, but the push update needs to wait for several days, unlike the minor version updates that are faster, sometimes it may be delayed for 10 days, maybe for security reasons, or maybe for batch push. I think, if you want to wait for your customers to solve this problem automatically, you need to wait for their machines to upgrade WebView2 automatically, which may take another two weeks.

@BenjaminGopp
Copy link

Deleting this entry worked for me!

image

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

No branches or pull requests

10 participants