onBrowserProcessExited property

  1. @SupportedPlatforms.new(platforms: [WindowsPlatform(available: '1.0.992.28+', apiName: 'ICoreWebView2Environment5.add_BrowserProcessExited', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment5?view=webview2-1.0.2849.39#add_browserprocessexited')])
void Function(BrowserProcessExitedDetail detail)? onBrowserProcessExited
getter/setter pair

The onBrowserProcessExited event is raised when the collection of WebView2 Runtime processes for the browser process of this environment terminate due to browser process failure or normal shutdown (for example, when all associated WebViews are closed), after all resources have been released (including the user data folder). To learn about what these processes are, go to Process model.

Multiple app processes can share a browser process by creating their webviews from a PlatformWebViewEnvironment with the same user data folder. When the entire collection of WebView2Runtime processes for the browser process exit, all associated PlatformWebViewEnvironment objects receive the onBrowserProcessExited event. Multiple processes sharing the same browser process need to coordinate their use of the shared user data folder to avoid race conditions and unnecessary waits. For example, one process should not clear the user data folder at the same time that another process recovers from a crash by recreating its WebView controls; one process should not block waiting for the event if other app processes are using the same browser process (the browser process will not exit until those other processes have closed their webviews too).

The difference between onBrowserProcessExited and PlatformWebViewCreationParams.onProcessFailed is that onBrowserProcessExited is raised for any browser process exit (expected or unexpected, after all associated processes have exited too), while PlatformWebViewCreationParams.onProcessFailed is raised for unexpected process exits of any kind (browser, render, GPU, and all other types), or for main frame render process unresponsiveness. To learn more about the WebView2 Process Model, go to Process model.

In the case the browser process crashes, both onBrowserProcessExited and PlatformWebViewCreationParams.onProcessFailed events are raised, but the order is not guaranteed. These events are intended for different scenarios. It is up to the app to coordinate the handlers so they do not try to perform reliability recovery while also trying to move to a new WebView2 Runtime version or remove the user data folder.

Officially Supported Platforms/Implementations:

Parameters - Officially Supported Platforms/Implementations:

  • detail: all platforms

Use the PlatformWebViewEnvironment.isPropertySupported method to check if this property is supported at runtime.

Implementation

@SupportedPlatforms(
  platforms: [
    WindowsPlatform(
      available: '1.0.992.28+',
      apiName: 'ICoreWebView2Environment5.add_BrowserProcessExited',
      apiUrl:
          'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment5?view=webview2-1.0.2849.39#add_browserprocessexited',
    ),
  ],
)
void Function(BrowserProcessExitedDetail detail)? onBrowserProcessExited;