I am experiencing the very same issue in my UWP app. I tried hard, but unfortunately I cannot reproduce the problem in a small example app and I cannot share my actual app with you.
Reproduction steps are the same as JackLee's, but it only takes 2 minutes of waiting instead of 10. I am navigating to the WebView2, staring at my screen (doing nothing) for 2 minutes and closing the app.
I am using Microsoft.UI.Xaml 2.8.0-prerelease.220118001
- Using an "old" WebView, the problem never arose. It started when I replaced the WebView by WebView2.
- You have to navigate to the WebView2. Just opening the app and not navigating to the WebView2 + wait for 2 min is not enough.
- If you just open and close the app quickly (and always navigate to WebView2, closing the app after a couple of seconds), it doesn't happen
- It happens both when installed via Visual Studio and when built and installed with the msixbundle.
- After restarting the PC, the app can be started / uninstalled again
- If it happens you can start the app as many times as you want, you will not get past the splash screen
- When it happens you can't uninstall the app (without restarting the PC first).
- If it occurs while debugging in Visual Studio, you can't exit the Visual Studio debugger at all (when you click on the red square, Visual Studio gets stuck)
While I can't share my source code with you, I can try to explain what I did:
- The WebView2 is embedded in a Grid, which is itself embedded in a UserControl.
- I am using SetVirtualHostNameToFolderMapping to map a folder within the LocalState folder to "viewer.local"
- I am navigating to an html file that the app placed in the folder. All of this works well and exactly as intended.