MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
449 stars 55 forks source link

Better WebView2 crash/debugging support needed #1914

Open andrei-ai opened 2 years ago

andrei-ai commented 2 years ago

After using WebView2 for an applications with high quality standards, I'm sure that Microsoft could work to improve on the following:

  1. better if WebView2 browser process creates a dump for every crash, instead of just reporting a “ProcessFailed” event. The “ProcessFailed” event should also contain more relevant details that could help on fixing. A recovery after a crash is a “no go” for us, we can just crash our application.
  2. better if the WebView2 have a flag to enable a “debug” logging (add logging hook for WebView2), so that we could understand the possible reasons for a crash, or do some improvements on our side based on how the WebView2 handles different situations.
  3. better documentation and availability of the “.pdb” files needed for the WebView2. Path to PDBs and a “how to”. On an application crash dump, the .pdb's for WebView2 couldn' be retrieved.
  4. better documentation needed for threading regarding browser calls, javascript interaction & events.

AB#31250610

champnic commented 2 years ago

Hey @andrei-ai -

  1. Crash dumps are located in the user data folder: <user data folder>\EBWebView\Crashpad\reports. We have been updating the ProcessFailed event to give more info such as the exit code, which process failed, and the reason for failure: https://docs.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2processfailedeventargs?view=webview2-dotnet-1.0.1056-prerelease
  2. A trace is the best way to currently capture debug info, but does require running a tool. We have a scenario on our backlog to improve logging in general, and I've linked this to that scenario.
    • @Syul968 to help with pdb.
  3. We do have some documentation on threading in general with WebView2, here: https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/threading-model Is there some specific information you think is missing or could be clarified?
Syul968 commented 2 years ago

Hi @andrei-ai,

Regarding the PDBs, we do make EmbeddedBrowserWebView.dll PDBs public for each WebView2 Runtime release.

Are these the symbols you are referring to? If so, Microsoft public symbol server explains how to setup the symbols path for public Microsoft symbols to be retrieved.

laultman commented 2 months ago

I'm attempting to use WebView2 on HoloLens2 native c++ with OpenXR. Naturally this is a UWP app without WinUI or XAML. HoloLens2 is very limited in debugging to start with and WebView2 doesn't help at all on the HL2. I have followed all the processes including HL2 required updates. Something is not loading before the app even gets started. All I get from the debugger is the "A dependent dll is missing." Supposedly the latest versions of Windows 11 on HL2 have the necessary WebView2 dlls. But it is clearly failing to load. I have no way to determine what is missing, failing to load, or what's happening at all. Any help, comments, experiences, would be appreciated.

Update: My app without the WebView2 runs fine in HL2. My implementation of WebView2 is a static wrapper of WebView2 that links WebView2Loader.dll.lib. Everything compiles and links in VS2022. My HoloLens is current with latest updates 24H1. I can build and execute the sample app for WebView2_uwp on ARM64 on the HL2. I don't understand what could be missing or why the loader is not loading the necessary dll files.

Syul968 commented 2 months ago

Hi @laultman,

If you're using the WinRT API (default for UWP projects), you don't need to link the static library as it's already linked, but you should make sure that the WinRT component Microsoft.Web.WebView2.Core.dll is in the output directory for your project.

Also, there might be additional details in the output window of Visual Studio if you launch the application from the IDE. Using Visual Studio to deploy and debug.

Hope this helps.

laultman commented 2 months ago

@Syul968 Thanks for the response! In the meantime I discovered that Microsoft.Web.WebView2.Core.dll and WebView2Loader.dll both in the deployed package. Once I figured this out, the app runs up to another point and crashes. It now creates the environment and registers the callback. On the callback it next creates the controller and its callback. This is where it is crashing now. The call to create the controller and register a callback are succeeding (S_OK). But somewhere in the process it is failing with the error, Procedure not found. That could be a lot of things. In this case they are all Microsoft code with the exception of the name of the callback. Stepping though the code in VS debugger it hits a point where it says the EmbeddedWebView2.dll.pdb file is not found. In VS I used the Additional Options and selected the checkbox the Microsoft Symbols Server. No luck! I have been stuck here for about 5 days. I have no idea how to fix it

Syul968 commented 2 months ago

@laultman for crashes please open a new issue with details on the crash. A stack or dump would be the most useful. If you have a sample project where the issue can be reproduced, that would be helpful as well. Open new issue.

laultman commented 2 months ago

@Syul968 I am implementing on HoloLens 2 in a native C++ using OpenXR. So, the platform is UWP on an ARM64. The app does not use Win32 UIs rather is using direct composition in the CoreWindow with the OpenXR and MS extensions. The debugging is via USB to dev computer (Intel x64) VS2022 17.11. Crash may not be the correct word. The debugger detects and error at runtime, Procedure not found. The app then terminates, I assume because I am not handling the error. I checked the HoloLens and there is no crash dump file.

I have no means to check for the failure. I am using the Microsoft OpenXR Samples as my template project. I am adding a C++ project to be a wrapper for the WebView2 to the samples solution just to get a working wrapper. After I get WV2 running and where I can simulate commands to the control, then I'll worry about making it work in HoloLens visibly with OpenXR.

I am putting together a test solution that I can send to you.