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 hosted by NavigationView/Frame/Page crashes app on exit #7632

Closed
Balkoth opened this issue Aug 19, 2022 · 3 comments
Closed

WebView2 hosted by NavigationView/Frame/Page crashes app on exit #7632

Balkoth opened this issue Aug 19, 2022 · 3 comments

Comments

@Balkoth
Copy link

Balkoth commented Aug 19, 2022

Describe the bug

If a WebView2 control is hosted in a Page which itself is navigated via a NavigationView/Frame and navigation happens a few times, the app crashes on exit with the following error message:
image
image

Steps to reproduce the bug

  1. Open the attached sample TestNavWebView.zip
  2. Build and run it
  3. Navigate 5 times between the 2 pages
  4. Exit the app and observere the above crash

Expected behavior

No response

Screenshots

No response

NuGet package version

1.1.4

Packaging type

Packaged (MSIX)

Windows version

Windows 10 version 21H2 (19044, November 2021 Update)

IDE

Visual Studio 2022

Additional context

No response

@Balkoth
Copy link
Author

Balkoth commented Aug 19, 2022

In the posted sample if you force a GC.Collect() after navigating you can observe the crash on exit right after the first navigation.

private void NavigationView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
{
  Type navigationTargetType = _navigationItemToPageDict[(NavigationViewItem)args.InvokedItemContainer];
  if (NavigationFrame.Content?.GetType() != navigationTargetType) { NavigationFrame.Navigate(navigationTargetType, null, new DrillInNavigationTransitionInfo()); }
  GC.Collect(); // Forces the crash!!!
}

@Balkoth
Copy link
Author

Balkoth commented Aug 19, 2022

The crash is also present in 1.2.220727.1-experimental1

@btueffers btueffers transferred this issue from microsoft/WindowsAppSDK Aug 22, 2022
@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Aug 22, 2022
@codendone
Copy link
Contributor

The problem here is the underlying WebView2 objects don't get closed soon enough. #7260 has more details, including the workaround to explicitly Close() any WebView2 elements before the app exits. We'll use that issue to track the platform fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants