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

[Problem/Bug]: winrt::hresult_error on app closing when WebView2 control presents in a WinUI3 app that is packaged with a separate WAP project #4814

Closed
aries-zhang opened this issue Sep 16, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@aries-zhang
Copy link

aries-zhang commented Sep 16, 2024

What happened?

With the following minimal XAML code in a skeleton WinUI 3 app created with the VisualStudio template "Blank App, Packaged with Windows Application Package Project (WinUI 3 in Desktop)":

<Grid>
    <WebView2 Source="https://bing.com"/>
</Grid>

The app crashes with the following exception when it is closed:
image

The exception does not occur with the same code in a project created with the template "Blank App, Packaged (WinUI 3 in Desktop)".

Please see the code in this repo: https://github.com/aries-zhang/winui3-adventure/tree/main/closing-exception-with-webview2

PackagedWithSameProject is for the 2nd scenario where the app does not crash on closing.
PackagedWithSeparateWapProject is for the 1st scenario where the issue repros.

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

128.0.2739.79

SDK Version

No response

Framework

WinUI3/WinAppSDK

Operating System

Windows 11

OS Version

23H2

Repro steps

  1. Create a new project in Visual Studio (2022) with the template "Blank App, Packaged with Windows Application Package Project (WinUI 3 in Desktop)".
  2. Open MainWindow.xaml in the new project, remove the <StackPanel ...> ... </StackPanel> code, add the following code:
<Grid>
    <WebView2 Source="https://bing.com"/>
</Grid>
  1. Run the app in Visual Studio with "Local Machine". The app should start and load Bing.com.
  2. Close the app, the following exception occurs:
    image
Exception thrown at 0x00007FFDDAFAFABC (KernelBase.dll) in App8.exe: WinRT originate error - 0x8007139F : 'The group or resource is not in the correct state to perform the requested operation.'.
Exception thrown at 0x00007FFDDAFAFABC in App8.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x000000234417D190.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

@aries-zhang aries-zhang added the bug Something isn't working label Sep 16, 2024
Copy link

Hi, @aries-zhang!

It seems that your issue contains the word "crash". If you have not already, could you attach a crash dump as a comment?

WV2 crash dumps are located in a subfolder of the app's user data folder (UDF): <UDF>\EBWebView\Crashpad\reports\. By default, the user data folder is created in the app's folder with a name like <App Exe Name>.exe.WebView2. Refer to Crash Diagnostics for more information.

Thank you for your cooperation!

@aries-zhang
Copy link
Author

aries-zhang commented Sep 16, 2024

No file exists under <UDF>\EBWebView\Crashpad\reports\.

@oggy22
Copy link
Member

oggy22 commented Sep 27, 2024

Hi @aries-zhang , can you please provide the SDK version number in the bug template?

@aries-zhang
Copy link
Author

Hi @oggy22 if you mean WinAppSDK version number it is 1.6.240829007 (project link).
There is no WebView2 SDK involved in this case since it's just a <WebView2 /> element in XAML.

@aries-zhang
Copy link
Author

Please see this issue in WinUI 3 repo for workaround: microsoft/microsoft-ui-xaml#7632.

Explicitly disposing WebView2 by calling TheWebView2Instance.Close() when app closes fixes the issue.

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

2 participants