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

Webview2 fails to initialize #4179

Open
kavya-kg opened this issue Nov 20, 2023 · 11 comments
Open

Webview2 fails to initialize #4179

kavya-kg opened this issue Nov 20, 2023 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@kavya-kg
Copy link

kavya-kg commented Nov 20, 2023

What happened?

Basically two types of exception occurs .The crashes are very in consistent.
One =>during Intialization of window
Inner Exception-> System.Runtime.InteropServices.COMException (0x8007139F): The group or resource is not in the correct state to perform the requested operation. (Exception from HRESULT: 0x8007139F) at Microsoft.Web.WebView2.Core.Raw.ICoreWebView2Controller.add_AcceleratorKeyPressed(ICoreWebView2AcceleratorKeyPressedEventHandler eventHandler, EventRegistrationToken& token) at Microsoft.Web.WebView2.Core.CoreWebView2Controller.add_AcceleratorKeyPressed(EventHandler`1 value)

Two=>during closing of window
Inner Exception-> System.Runtime.InteropServices.COMException (0x8007139F): The group or resource is not in the correct state to perform the requested operation. (Exception from HRESULT: 0x8007139F) at Microsoft.Web.WebView2.Core.Raw.ICoreWebView2.ExecuteScript(String javaScript, ICoreWebView2ExecuteScriptCompletedHandler handler) at Microsoft.Web.WebView2.Core.CoreWebView2.d__133.MoveNext()

Importance

Blocking. My app's basic functions are not working due to this issue.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

119.0.2151.72

SDK Version

1.0.1418.22

Framework

WPF

Operating System

Windows 10

OS Version

10.0.19045

Repro steps

there is no steps.

Repros in Edge Browser

Not Applicable

Regression

Don't know

Last working version (if regression)

No response

@kavya-kg kavya-kg added the bug Something isn't working label Nov 20, 2023
@vbryh-msft
Copy link
Contributor

Hi - do I understand the issue correctly - you are not able to initialize WebView2 at all? Have you looked into our SampleApp?

@kavya-kg
Copy link
Author

Yes I have. The issue has been reported from our customer end. We are able to initialize WebView2 but at times it fails which we can't figure out. Mostly after relaunch of application.

@vbryh-msft
Copy link
Contributor

I see. So 0x8007139F error means that there is already browser process running in the user data folder with different configuration from the one you are trying to create. For example: different DPI awareness, different environment options or exclusiveuserdatafolderaccess flag is on. If you are able to collect the traces we can look into it.

@fdzatdtv
Copy link

@vbryh-msft
We have also a lot of 0x8007139F failures. We tried the ETW trace as recommended. But it fails. The following output is from a console with admin rights:

C:\webview_test>wpr -start WebView2_CPU.wprp -filemode
C:\webview_test>wpr -stop trace.etl "trace"

        Cannot change thread mode after it is set.
        Profile Id: RunningProfile
        Error code: 0x80010106

C:\webview_test>

Run on OS:

Edition Windows 10 Enterprise
Version           22H2
Installiert am  ‎14.‎04.‎2022
Betriebssystembuild  19045.3693
Leistung         Windows Feature Experience Pack 1000.19053.1000.0

@vbryh-msft
Copy link
Contributor

vbryh-msft commented Nov 28, 2023

@fdzatdtv This blog says that when facing that error you need Please use the insider version of ADK Windows Performance Toolkit, build 19650 or later - have you tried to update wpr? Also - have you checked that you are not starting webview2 with different configuration from the same user data folder?

@xinguangtai
Copy link

xinguangtai commented Nov 29, 2023

@vbryh-msft Hi, I also encountered this problem,

The scenario is as follows:
in Word VSTO Add-in, we initialize WebView2 first, then another tool in Word initializes its WebView2 environment, and then when we initialize a new WebView2, we get this exception (only if the other tool's operation is in the middle of ours).

We have been launching webview2 with the same configuration from the same user data folder
For this issue, launching webview2 from a different user data folder each time solves the problem. But it's not desired because there are a lot of front-end communication operations that don't want to be isolated

@fdzatdtv
Copy link

@fdzatdtv This blog says that when facing that error you need Please use the insider version of ADK Windows Performance Toolkit, build 19650 or later - have you tried to update wpr? Also - have you checked that you are not starting webview2 with different configuration from the same user data folder?

We have a class for initializing all the webview2 instances with the same environment and UDF. In addition, we synchronize all the inits to not run into a concurrent init. For the case of cross-process inits we have proved that there aren't any. Some of our applications have their own UDF to not disturb other applications.

@vbryh-msft It's not acceptable to require an insider version of the ADK since this requires to be member of the insider programm and to install software that is not public available. Please provide an alternative wprp file we can work with.
Thank you in advance.

@vbryh-msft
Copy link
Contributor

vbryh-msft commented Dec 1, 2023

@fdzatdtv here is another wprp profile which is good for this purpose - could you try it? What is the version of your wpr? I have tried the one downloaded from here - it is 10.0.14393 and it worked.

@fdzatdtv
Copy link

fdzatdtv commented Dec 1, 2023

@vbryh-msft My wpr version is: Microsoft Windows Performance Recorder Version 10.0.19041 (CoreSystem)

I tried your wprp file, but it fails too:

D:\tmp\wpr_test>wpr -start WebView2.wprp -filemode

D:\tmp\wpr_test>wpr -stop trace.etl "trace"

        Cannot change thread mode after it is set.

        Profile Id: RunningProfile

        Error code: 0x80010106

D:\tmp\wpr_test>

@kodybrown
Copy link

I ran the wpr trace. It seems like it worked and I have a 292 MB trace.etl file. What do I do with it? ☺

@kodybrown
Copy link

I should add that my app works just fine on Windows 11. 👍

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

5 participants