MicrosoftEdge / MicrosoftEdge/WebView2Feedback

Edge webview initialization failing during shutting down of system

Open
#3,574 4 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

During the system shutting down, some edgewebview process is exiting causing the below exception:
ProcessFailedException in View : Browser Process failed having process failed kind as: RenderProcessExited, Reason: Unexpected, Description: , Framed information for the failed process: and Exit code is :0. Sender details as Microsoft.Web.WebView2.Core.CoreWebView2 and browser process version is 112.0.1722.68

To handle the above scenario we registered one event handler for ProcessFailed event which tries to initialize webview again: edgeWebView.CoreWebView2.ProcessFailed += CoreWebView2_ProcessFailed;

During initialization we are getting the following error:
System.Exception: Exception occur while Initializing Edge webview2:System.Runtime.InteropServices.COMException (0x80070270): {DLL Initialization Failed} The application failed to initialize because the window station is shutting down. (Exception from HRESULT: 0x80070270)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.Web.WebView2.Core.CoreWebView2Environment.d__45.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Web.WebView2.Wpf.WebView2.<>c__DisplayClass27_0.<g__Init|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at <b__23_0>d.MoveNext()

I tried to capture SystemEvents.SessionEnding to set a flag and use the flag to manage initialization but edgewebview initialization is occuring before the capturing of the SessionEnding event, so basically the flag is not setting.
Is there any better way to handle this scenario like ProcessFailed event should not be triggered if system is shutting down?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.