From 450f0da558a8ff5d891faa7ef269be9222c39e2d Mon Sep 17 00:00:00 2001 From: Priyank Jain Date: Wed, 22 Oct 2025 14:48:09 +0530 Subject: [PATCH 1/5] API Review: ProcessId for ProcessFailedEventArgs Add ProcessId property to CoreWebView2ProcessFailedEventArgs4 This API extends ProcessFailedEventArgs to include the process ID of the failed process, enabling applications to: - Correlate process failures with running process data from the ProcessInfo API - Collect process-specific diagnostic information for logging and telemetry - Analyze crash dumps for specific processes - Better track and respond to failures in multi-renderer scenarios The process ID is only available if the process has started and ended unexpectedly. For other failure types, the process ID value will be 0. --- specs/api-get_ProcessId.md | 168 +++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 specs/api-get_ProcessId.md diff --git a/specs/api-get_ProcessId.md b/specs/api-get_ProcessId.md new file mode 100644 index 00000000..31e12ae6 --- /dev/null +++ b/specs/api-get_ProcessId.md @@ -0,0 +1,168 @@ +Process ID When a WebView2 Process Fails +=== + +# Background + +WebView2 provides applications with the [ProcessFailed](https://learn.microsoft.com/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.705.50#add_processfailed) event so they can react accordingly when a process failure occurs. However, this event does not currently provide the process id of the failed process. This is particularly problematic when running multiple renderers, it becomes difficult for the application to determine which process to address. + +In this document we describe an extended version of the [ProcessFailedEventArgs](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2processfailedeventargs?view=webview2-1.0.2151.40), which includes the process id. This enables the host application to collect additional information about the process failure whether a renderer, GPU, or even the browser process. + +The updated API is detailed below. We'd appreciate your feedback. + +# Description + +The `ICoreWebView2ProcessFailedEventArgs4` interface extends the existing `ProcessFailedEventArgs` to include the process ID of the failed process. This enables applications to: +- Correlate process failures with running process data from the ProcessInfo API +- Collect process-specific diagnostic information for logging and telemetry +- Analyze crash dumps for specific processes +- Better track and respond to failures in multi-renderer scenarios + +The process ID is only available if the process has started and ended unexpectedly. For other failure types where the process was never successfully started, the process ID value will be `0`. + +# Examples + +The following code snippets demonstrate how the updated `ProcessFailedEventArgs` can be used by the host application: + +## Win32 C++ + +```cpp +//! [ProcessFailed] +// Register a handler for the ProcessFailed event. + // This handler checks the failure kind and tries to: + // * Recreate the webview for browser failure and render unresponsive. + // * Reload the webview for render failure. + // * Reload the webview for frame-only render failure impacting app content. + // * Log information about the failure for other failures. +CHECK_FAILURE(m_webView->add_ProcessFailed( + Callback( + [this](ICoreWebView2* sender, ICoreWebView2ProcessFailedEventArgs* argsRaw) + -> HRESULT { + wil::com_ptr args = argsRaw; + COREWEBVIEW2_PROCESS_FAILED_KIND kind; + CHECK_FAILURE(args->get_ProcessFailedKind(&kind)); + + // Try to get the newer interface with additional failure details + auto args2 = args.try_query(); + if (args2) + { + COREWEBVIEW2_PROCESS_FAILED_REASON reason; + wil::unique_cotaskmem_string processDescription; + INT32 exitCode; + CHECK_FAILURE(args2->get_Reason(&reason)); + CHECK_FAILURE(args2->get_ProcessDescription(&processDescription)); + CHECK_FAILURE(args2->get_ExitCode(&exitCode)); + + // Get the process ID of the failed process + INT32 processId = 0; + auto args4 = args.try_query(); + if (args4) + { + CHECK_FAILURE(args4->get_ProcessId(&processId)); + } + + // Log the failure details including the process ID + std::wstringstream message; + message << L"Kind: " << ProcessFailedKindToString(kind) << L"\n" + << L"Reason: " << ProcessFailedReasonToString(reason) << L"\n" + << L"Exit code: " << exitCode << L"\n" + << L"Process ID: " << processId << L"\n" + << L"Process description: " << processDescription.get(); + + OutputDebugString(message.str().c_str()); + // Collect the process ID for telemetry or further analysis + } + return S_OK; + }) + .Get(), + &m_processFailedToken)); +//! [ProcessFailed] +``` + +## .NET C# + +```c# +void WebView_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e) +{ + if (e.IsSuccess) + { + webView.CoreWebView2.ProcessFailed += WebView_ProcessFailed; + } +} + +void WebView_ProcessFailed(object sender, CoreWebView2ProcessFailedEventArgs e) +{ + // Collect failure details including the process ID + StringBuilder messageBuilder = new StringBuilder(); + messageBuilder.AppendLine($"Process kind: {e.ProcessFailedKind}"); + messageBuilder.AppendLine($"Reason: {e.Reason}"); + messageBuilder.AppendLine($"Exit code: {e.ExitCode}"); + messageBuilder.AppendLine($"Process description: {e.ProcessDescription}"); + + // Get the process ID of the failed process + messageBuilder.AppendLine($"Process ID: {e.ProcessId}"); + + // Log the failure or send to telemetry + System.Diagnostics.Debug.WriteLine(messageBuilder.ToString()); + + // You can also correlate with process info collected earlier + var failedProcessInfo = _processInfoList.FirstOrDefault(p => p.ProcessId == e.ProcessId); + if (failedProcessInfo != null) + { + System.Diagnostics.Debug.WriteLine( + $"Failed process was of kind: {failedProcessInfo.Kind}"); + } +} +``` + +# Remarks + +The `ProcessId` property returns the process ID of the failed process, which matches the `ProcessId` property in the `CoreWebView2ProcessInfo` interface from the ProcessInfo API. This allows you to correlate process failures with process information collected during normal operation. + +The process ID is only available if the process has started and ended unexpectedly. For other failure types where the process was never successfully started or in scenarios where the process ID is not available, the `ProcessId` value will be `0`. Applications should check for this value before attempting to use the process ID. + +# API Details + +## COM + +```cpp + +/// A continuation of the ICoreWebView2ProcessFailedEventArgs3 interface +/// for getting the process ID of the failed process. +/// +[uuid(f71c6e90-b2dc-4f81-bb56-bb3ef56dd8c7), object, pointer_default(unique)] +interface ICoreWebView2ProcessFailedEventArgs4 : ICoreWebView2ProcessFailedEventArgs3 { + /// The process ID of the failed process. It will match the `ProcessId` + /// property in `ICoreWebView2ProcessInfo` interface, which can be used to + /// correlate the failing process with the running process data or to + /// analyze crash dumps for that process. The process ID is only available + /// if the process has started and ended unexpectedly. For other failure + /// types, the process ID value will be `0`. + /// + // MSOWNERS: core (acharif@microsoft.com) + [propget] HRESULT ProcessId([out, retval] INT32* value); +} + +``` + +## .NET / WinRT + +```c# +namespace Microsoft.Web.WebView2.Core +{ + runtimeclass CoreWebView2ProcessFailedEventArgs + { + /// The process ID of the failed process. It will match the `ProcessId` + /// property in `ICoreWebView2ProcessInfo` interface, which can be used to + /// correlate the failing process with the running process data or to + /// analyze crash dumps for that process. The process ID is only available + /// if the process has started and ended unexpectedly. For other failure + /// types, the process ID value will be `0`. + /// + [interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2ProcessFailedEventArgs4")] + { + Int32 ProcessId { get; }; + } + } +} +``` + From d7d65f6d74f93e62665a0875298c9bdc8ba78015 Mon Sep 17 00:00:00 2001 From: Priyank Jain Date: Fri, 31 Oct 2025 19:57:47 +0530 Subject: [PATCH 2/5] updating owner to webview2 core alias --- specs/api-get_ProcessId.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/api-get_ProcessId.md b/specs/api-get_ProcessId.md index 31e12ae6..2c6938d8 100644 --- a/specs/api-get_ProcessId.md +++ b/specs/api-get_ProcessId.md @@ -138,7 +138,7 @@ interface ICoreWebView2ProcessFailedEventArgs4 : ICoreWebView2ProcessFailedEvent /// if the process has started and ended unexpectedly. For other failure /// types, the process ID value will be `0`. /// - // MSOWNERS: core (acharif@microsoft.com) + // MSOWNERS: core (wvcore@microsoft.com) [propget] HRESULT ProcessId([out, retval] INT32* value); } From c1804e217e04b76adba784ea2590b94d9f69395b Mon Sep 17 00:00:00 2001 From: Priyank Jain Date: Tue, 11 Nov 2025 14:08:57 +0530 Subject: [PATCH 3/5] Review comments --- specs/api-get_ProcessId.md | 130 +++++++++++++++++++++++-------------- 1 file changed, 81 insertions(+), 49 deletions(-) diff --git a/specs/api-get_ProcessId.md b/specs/api-get_ProcessId.md index 2c6938d8..d8d9a257 100644 --- a/specs/api-get_ProcessId.md +++ b/specs/api-get_ProcessId.md @@ -1,27 +1,37 @@ -Process ID When a WebView2 Process Fails +Process Info When a WebView2 Process Fails === # Background -WebView2 provides applications with the [ProcessFailed](https://learn.microsoft.com/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.705.50#add_processfailed) event so they can react accordingly when a process failure occurs. However, this event does not currently provide the process id of the failed process. This is particularly problematic when running multiple renderers, it becomes difficult for the application to determine which process to address. +WebView2 provides applications with the +[ProcessFailed](https://learn.microsoft.com/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.705.50#add_processfailed) +event so they can react accordingly when a process failure occurs. However, +this event does not currently provide the process ID of the failed process. +This is particularly problematic when running multiple renderers, it becomes +difficult for the application to determine which process to address. -In this document we describe an extended version of the [ProcessFailedEventArgs](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2processfailedeventargs?view=webview2-1.0.2151.40), which includes the process id. This enables the host application to collect additional information about the process failure whether a renderer, GPU, or even the browser process. +In this document we describe an extended version of the +[ProcessFailedEventArgs](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2processfailedeventargs?view=webview2-1.0.2151.40), +which includes the process ID and the process kind. This enables the host application to collect +additional information about the process failure whether a renderer, GPU, or +even the browser process. The updated API is detailed below. We'd appreciate your feedback. # Description -The `ICoreWebView2ProcessFailedEventArgs4` interface extends the existing `ProcessFailedEventArgs` to include the process ID of the failed process. This enables applications to: +The `ICoreWebView2ProcessFailedEventArgs4` interface extends the existing +`ProcessFailedEventArgs` to include the ICoreWebView2ProcessInfo of the failed process. This +enables applications to: - Correlate process failures with running process data from the ProcessInfo API - Collect process-specific diagnostic information for logging and telemetry - Analyze crash dumps for specific processes - Better track and respond to failures in multi-renderer scenarios -The process ID is only available if the process has started and ended unexpectedly. For other failure types where the process was never successfully started, the process ID value will be `0`. - # Examples -The following code snippets demonstrate how the updated `ProcessFailedEventArgs` can be used by the host application: +The following code snippets demonstrate how the updated +`ProcessFailedEventArgs` can be used by the host application: ## Win32 C++ @@ -31,45 +41,61 @@ The following code snippets demonstrate how the updated `ProcessFailedEventArgs` // This handler checks the failure kind and tries to: // * Recreate the webview for browser failure and render unresponsive. // * Reload the webview for render failure. - // * Reload the webview for frame-only render failure impacting app content. + // * Reload the webview for frame-only render failure impacting app + // content. // * Log information about the failure for other failures. CHECK_FAILURE(m_webView->add_ProcessFailed( Callback( - [this](ICoreWebView2* sender, ICoreWebView2ProcessFailedEventArgs* argsRaw) + [this](ICoreWebView2* sender, + ICoreWebView2ProcessFailedEventArgs* argsRaw) -> HRESULT { wil::com_ptr args = argsRaw; COREWEBVIEW2_PROCESS_FAILED_KIND kind; CHECK_FAILURE(args->get_ProcessFailedKind(&kind)); - + // Try to get the newer interface with additional failure details - auto args2 = args.try_query(); + auto args2 = + args.try_query(); if (args2) { COREWEBVIEW2_PROCESS_FAILED_REASON reason; wil::unique_cotaskmem_string processDescription; INT32 exitCode; CHECK_FAILURE(args2->get_Reason(&reason)); - CHECK_FAILURE(args2->get_ProcessDescription(&processDescription)); + CHECK_FAILURE( + args2->get_ProcessDescription(&processDescription)); CHECK_FAILURE(args2->get_ExitCode(&exitCode)); // Get the process ID of the failed process + wil::com_ptr processInfo; + auto argProcessinfo = args.try_query(); + if (argProcessinfo) + { + CHECK_FAILURE(argProcessinfo->get_ProcessInfo(&processInfo)); + } INT32 processId = 0; - auto args4 = args.try_query(); - if (args4) + COREWEBVIEW2_PROCESS_KIND processKind; + if(processInfo) { - CHECK_FAILURE(args4->get_ProcessId(&processId)); + CHECK_FAILURE(processInfo->get_ProcessId(&processId)); + processInfo->get_Kind(&processKind); } // Log the failure details including the process ID std::wstringstream message; - message << L"Kind: " << ProcessFailedKindToString(kind) << L"\n" - << L"Reason: " << ProcessFailedReasonToString(reason) << L"\n" + message << L"Kind: " << ProcessFailedKindToString(kind) + << L"\n" + << L"Reason: " << ProcessFailedReasonToString(reason) + << L"\n" << L"Exit code: " << exitCode << L"\n" << L"Process ID: " << processId << L"\n" - << L"Process description: " << processDescription.get(); - + << L"Process Kind: " << ProcessKindToString(processKind) << L"\n" + << L"Process description: " + << processDescription.get(); + OutputDebugString(message.str().c_str()); - // Collect the process ID for telemetry or further analysis + // Collect the process ID for telemetry or further + // analysis } return S_OK; }) @@ -81,7 +107,8 @@ CHECK_FAILURE(m_webView->add_ProcessFailed( ## .NET C# ```c# -void WebView_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e) +void WebView_CoreWebView2InitializationCompleted(object sender, + CoreWebView2InitializationCompletedEventArgs e) { if (e.IsSuccess) { @@ -89,23 +116,27 @@ void WebView_CoreWebView2InitializationCompleted(object sender, CoreWebView2Init } } -void WebView_ProcessFailed(object sender, CoreWebView2ProcessFailedEventArgs e) +void WebView_ProcessFailed(object sender, + CoreWebView2ProcessFailedEventArgs e) { // Collect failure details including the process ID StringBuilder messageBuilder = new StringBuilder(); messageBuilder.AppendLine($"Process kind: {e.ProcessFailedKind}"); messageBuilder.AppendLine($"Reason: {e.Reason}"); messageBuilder.AppendLine($"Exit code: {e.ExitCode}"); - messageBuilder.AppendLine($"Process description: {e.ProcessDescription}"); - + messageBuilder.AppendLine( + $"Process description: {e.ProcessDescription}"); + // Get the process ID of the failed process - messageBuilder.AppendLine($"Process ID: {e.ProcessId}"); - + messageBuilder.AppendLine($"Process Id: {e.ProcessInfo.ProcessId}"); + messageBuilder.AppendLine($"Process Kind: {e.ProcessInfo.Kind}"); + // Log the failure or send to telemetry System.Diagnostics.Debug.WriteLine(messageBuilder.ToString()); - + // You can also correlate with process info collected earlier - var failedProcessInfo = _processInfoList.FirstOrDefault(p => p.ProcessId == e.ProcessId); + var failedProcessInfo = _processInfoList.FirstOrDefault( + p => p.ProcessId == e.ProcessId); if (failedProcessInfo != null) { System.Diagnostics.Debug.WriteLine( @@ -116,9 +147,8 @@ void WebView_ProcessFailed(object sender, CoreWebView2ProcessFailedEventArgs e) # Remarks -The `ProcessId` property returns the process ID of the failed process, which matches the `ProcessId` property in the `CoreWebView2ProcessInfo` interface from the ProcessInfo API. This allows you to correlate process failures with process information collected during normal operation. - -The process ID is only available if the process has started and ended unexpectedly. For other failure types where the process was never successfully started or in scenarios where the process ID is not available, the `ProcessId` value will be `0`. Applications should check for this value before attempting to use the process ID. +The `ICoreWebView2ProcessInfo` property contains the process ID of the failed process +and the process kind (GPU, Renderer, Browser, Utility, etc..) # API Details @@ -129,17 +159,19 @@ The process ID is only available if the process has started and ended unexpected /// A continuation of the ICoreWebView2ProcessFailedEventArgs3 interface /// for getting the process ID of the failed process. /// -[uuid(f71c6e90-b2dc-4f81-bb56-bb3ef56dd8c7), object, pointer_default(unique)] -interface ICoreWebView2ProcessFailedEventArgs4 : ICoreWebView2ProcessFailedEventArgs3 { - /// The process ID of the failed process. It will match the `ProcessId` - /// property in `ICoreWebView2ProcessInfo` interface, which can be used to +[uuid(f71c6e90-b2dc-4f81-bb56-bb3ef56dd8c7), object, + pointer_default(unique)] +interface ICoreWebView2ProcessFailedEventArgs4 : + ICoreWebView2ProcessFailedEventArgs3 { + /// The process info of the failed process, which can be used to /// correlate the failing process with the running process data or to - /// analyze crash dumps for that process. The process ID is only available - /// if the process has started and ended unexpectedly. For other failure - /// types, the process ID value will be `0`. - /// + /// analyze crash dumps for that process. The process ID should be + // available in all failure kinds e.g. when GPU process hags, + // browser process exits, utility process exits or renderer process hangs. + // if the main frame renderer process is gone externally, the process id + // will be set to 0. // MSOWNERS: core (wvcore@microsoft.com) - [propget] HRESULT ProcessId([out, retval] INT32* value); + [propget] HRESULT ProcessInfo([out, retval] ICoreWebView2ProcessInfo* value); } ``` @@ -151,18 +183,18 @@ namespace Microsoft.Web.WebView2.Core { runtimeclass CoreWebView2ProcessFailedEventArgs { - /// The process ID of the failed process. It will match the `ProcessId` - /// property in `ICoreWebView2ProcessInfo` interface, which can be used to - /// correlate the failing process with the running process data or to - /// analyze crash dumps for that process. The process ID is only available - /// if the process has started and ended unexpectedly. For other failure - /// types, the process ID value will be `0`. - /// + /// The process info of the failed process, which can be used to + /// correlate the failing process with the running process data or to + /// analyze crash dumps for that process. The process ID should be + // available in all failure kinds e.g. when GPU process hags, + // browser process exits, utility process exits or renderer process hangs. + // if the main frame renderer process is gone externally, the process id + // will be set to 0. + [interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2ProcessFailedEventArgs4")] { - Int32 ProcessId { get; }; + CoreWebView2ProcessInfo ProcessInfo { get; }; } } } ``` - From a7fc1a3d1c4dfc6ffe3bfc324f590816bca4036e Mon Sep 17 00:00:00 2001 From: Priyank Jain Date: Tue, 11 Nov 2025 14:38:36 +0530 Subject: [PATCH 4/5] nit comments --- specs/api-get_ProcessId.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/specs/api-get_ProcessId.md b/specs/api-get_ProcessId.md index d8d9a257..eaf3c551 100644 --- a/specs/api-get_ProcessId.md +++ b/specs/api-get_ProcessId.md @@ -21,7 +21,7 @@ The updated API is detailed below. We'd appreciate your feedback. # Description The `ICoreWebView2ProcessFailedEventArgs4` interface extends the existing -`ProcessFailedEventArgs` to include the ICoreWebView2ProcessInfo of the failed process. This +`ProcessFailedEventArgs` to include the `ICoreWebView2ProcessInfo` of the failed process. This enables applications to: - Correlate process failures with running process data from the ProcessInfo API - Collect process-specific diagnostic information for logging and telemetry @@ -67,15 +67,15 @@ CHECK_FAILURE(m_webView->add_ProcessFailed( CHECK_FAILURE(args2->get_ExitCode(&exitCode)); // Get the process ID of the failed process - wil::com_ptr processInfo; - auto argProcessinfo = args.try_query(); - if (argProcessinfo) + wil::com_ptr processInfo; + auto argProcessInfo = args.try_query(); + if (argProcessInfo) { - CHECK_FAILURE(argProcessinfo->get_ProcessInfo(&processInfo)); + CHECK_FAILURE(argProcessInfo->get_ProcessInfo(&processInfo)); } INT32 processId = 0; COREWEBVIEW2_PROCESS_KIND processKind; - if(processInfo) + if (processInfo) { CHECK_FAILURE(processInfo->get_ProcessId(&processId)); processInfo->get_Kind(&processKind); @@ -128,7 +128,7 @@ void WebView_ProcessFailed(object sender, $"Process description: {e.ProcessDescription}"); // Get the process ID of the failed process - messageBuilder.AppendLine($"Process Id: {e.ProcessInfo.ProcessId}"); + messageBuilder.AppendLine($"Process ID: {e.ProcessInfo.ProcessId}"); messageBuilder.AppendLine($"Process Kind: {e.ProcessInfo.Kind}"); // Log the failure or send to telemetry @@ -166,10 +166,10 @@ interface ICoreWebView2ProcessFailedEventArgs4 : /// The process info of the failed process, which can be used to /// correlate the failing process with the running process data or to /// analyze crash dumps for that process. The process ID should be - // available in all failure kinds e.g. when GPU process hags, - // browser process exits, utility process exits or renderer process hangs. - // if the main frame renderer process is gone externally, the process id - // will be set to 0. + /// available in all failure kinds e.g. when GPU process hangs, + /// browser process exits, utility process exits or renderer process hangs. + /// If the main frame renderer process is gone externally, the process ID + /// will be set to 0. // MSOWNERS: core (wvcore@microsoft.com) [propget] HRESULT ProcessInfo([out, retval] ICoreWebView2ProcessInfo* value); } @@ -186,10 +186,10 @@ namespace Microsoft.Web.WebView2.Core /// The process info of the failed process, which can be used to /// correlate the failing process with the running process data or to /// analyze crash dumps for that process. The process ID should be - // available in all failure kinds e.g. when GPU process hags, - // browser process exits, utility process exits or renderer process hangs. - // if the main frame renderer process is gone externally, the process id - // will be set to 0. + /// available in all failure kinds e.g. when GPU process hangs, + /// browser process exits, utility process exits or renderer process hangs. + /// If the main frame renderer process is gone externally, the process ID + /// will be set to 0. [interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2ProcessFailedEventArgs4")] { From 99e3a98f9590cca5b0508490e1977bb505b814e4 Mon Sep 17 00:00:00 2001 From: Priyank Jain Date: Tue, 11 Nov 2025 14:56:44 +0530 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- specs/api-get_ProcessId.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/specs/api-get_ProcessId.md b/specs/api-get_ProcessId.md index eaf3c551..f8661e34 100644 --- a/specs/api-get_ProcessId.md +++ b/specs/api-get_ProcessId.md @@ -74,11 +74,11 @@ CHECK_FAILURE(m_webView->add_ProcessFailed( CHECK_FAILURE(argProcessInfo->get_ProcessInfo(&processInfo)); } INT32 processId = 0; - COREWEBVIEW2_PROCESS_KIND processKind; + COREWEBVIEW2_PROCESS_KIND processKind = COREWEBVIEW2_PROCESS_KIND_UNKNOWN; if (processInfo) { CHECK_FAILURE(processInfo->get_ProcessId(&processId)); - processInfo->get_Kind(&processKind); + CHECK_FAILURE(processInfo->get_Kind(&processKind)); } // Log the failure details including the process ID @@ -128,15 +128,22 @@ void WebView_ProcessFailed(object sender, $"Process description: {e.ProcessDescription}"); // Get the process ID of the failed process - messageBuilder.AppendLine($"Process ID: {e.ProcessInfo.ProcessId}"); - messageBuilder.AppendLine($"Process Kind: {e.ProcessInfo.Kind}"); + if (e.ProcessInfo != null) + { + messageBuilder.AppendLine($"Process ID: {e.ProcessInfo.ProcessId}"); + messageBuilder.AppendLine($"Process Kind: {e.ProcessInfo.Kind}"); + } + else + { + messageBuilder.AppendLine("Process Info: unavailable (process may be gone externally)"); + } // Log the failure or send to telemetry System.Diagnostics.Debug.WriteLine(messageBuilder.ToString()); // You can also correlate with process info collected earlier var failedProcessInfo = _processInfoList.FirstOrDefault( - p => p.ProcessId == e.ProcessId); + p => p.ProcessId == e.ProcessInfo.ProcessId); if (failedProcessInfo != null) { System.Diagnostics.Debug.WriteLine( @@ -148,7 +155,7 @@ void WebView_ProcessFailed(object sender, # Remarks The `ICoreWebView2ProcessInfo` property contains the process ID of the failed process -and the process kind (GPU, Renderer, Browser, Utility, etc..) +and the process kind (GPU, Renderer, Browser, Utility, etc.) # API Details