Skip to content

Commit de31420

Browse files
committed
Make clearer the event is raised after all environment-associated processes exit
1 parent 0fb1157 commit de31420

1 file changed

Lines changed: 49 additions & 42 deletions

File tree

specs/BrowserProcessExited.md

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
We have heard asks for a WebView2 API to easily track the WebView2 Runtime's
33
browser process exit. Manually waiting for the process to exit requires
44
additional work on the host app, so we are proposing the `BrowserProcessExited`
5-
event. The `ProcessFailed` already lets app developers handle unexpected browser
6-
process exits for a WebView, this new API lets you listen to both expected and
7-
unexpected process termination from the `ICoreWebView2Environment3` interface so
8-
you can, e.g., cleanup the user data folder when it's no longer in use. In this
9-
document we describe the new API. We'd appreciate your feedback.
5+
event. The `ProcessFailed` event already lets app developers handle unexpected
6+
browser process exits for a WebView, this new API lets you listen to both
7+
expected and unexpected termination of the processes associated to an
8+
environment from the `ICoreWebView2Environment3` interface so you can, e.g.,
9+
cleanup the user data folder when it's no longer in use. In this document we
10+
describe the new API. We'd appreciate your feedback.
1011

1112

1213
# Description
1314
The `BrowserProcessExited` event allows developers to subscribe event handlers
14-
to be run when the WebView2 Runtime's browser process associated to a
15-
`CoreWebView2Environment` terminates. Key scenarios are cleanup of the use data
16-
folder used by the WebView2 Runtime, which is locked while the runtime's
17-
browser process is active, and moving to a new WebView2 Runtime version after
18-
a `NewBrowserVersionAvailable` event.
15+
to be run when the WebView2 Runtime processes (including the browser process)
16+
associated to a `CoreWebView2Environment` terminate. Key scenarios are cleanup
17+
of the user data folder used by the WebView2 Runtime, which is locked while the
18+
runtime's browser process is active, and moving to a new WebView2 Runtime
19+
version after a `NewBrowserVersionAvailable` event.
1920

2021
This event is raised for both expected and unexpected browser process
2122
termination, after all resources, including the user data folder, used by the
@@ -29,12 +30,13 @@ is already registered. In case of a browser process crash, both
2930
not guaranteed.
3031

3132
All `CoreWebView2Environment` objects across different app processes that use
32-
the same browser process receive this event when the browser process exits.
33-
If the browser process (and therefore the user data folder) in use by the app
34-
process (through the `CoreWebView2Environment` options used) is shared with
35-
other processes, these processes need to coordinate to handle the potential race
36-
condition on the use of the resources. E.g., if one app process tries to clear
37-
the user data folder, while other tries to recreate its WebViews on crash.
33+
the same browser process receive this event when the browser process (and
34+
associated processes) exits. If the browser process (and therefore the user data
35+
folder) in use by the app process (through the `CoreWebView2Environment` options
36+
used) is shared with other processes, these processes need to coordinate to
37+
handle the potential race condition on the use of the resources. E.g., if one
38+
app process tries to clear the user data folder, while other tries to recreate
39+
its WebViews on crash.
3840

3941

4042
# Examples
@@ -145,10 +147,11 @@ void ReinitializeWebView()
145147
Note this is an event from the `ICoreWebView2Environment3` interface, not the
146148
`ICoreWebView2`. The difference between this `BrowserProcessExited` event and
147149
the `CoreWebView2`'s `ProcessFailed` event is that `BrowserProcessExited` is
148-
raised for any (expected and unexpected) **browser process** exits, while
149-
`ProcessFailed` is raised only for **unexpected** browser process exits, or for
150-
**render process** exits/unresponsiveness. To learn more about the WebView2
151-
Process Model, go to [Process model](https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/process-model).
150+
raised for any (expected and unexpected) **browser process** (along its
151+
associated processes) exits, while `ProcessFailed` is raised only for
152+
**unexpected** browser process exits, or for **render process**
153+
exits/unresponsiveness. To learn more about the WebView2 Process Model, go to
154+
[Process model](https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/process-model).
152155

153156
In the case the browser process crashes, both `BrowserProcessExited` and
154157
`ProcessFailed` events are raised, but the order is not guaranteed.
@@ -194,20 +197,22 @@ interface ICoreWebView2Environment3 : ICoreWebView2Environment2
194197
/// this environment after earlier `BrowserProcessExited` events are raised.
195198
///
196199
/// All `CoreWebView2Environment` objects across different app processes that use
197-
/// the same browser process receive this event when the browser process exits.
198-
/// If the browser process (and therefore the user data folder) in use by the app
199-
/// process (through the `CoreWebView2Environment` options used) is shared with
200-
/// other processes, these processes need to coordinate to handle the potential race
201-
/// condition on the use of the resources. E.g., if one app process tries to clear
202-
/// the user data folder, while other tries to recreate its WebViews on crash.
200+
/// the same browser process receive this event when the browser process (and
201+
/// associated processes) exits. If the browser process (and therefore the user data
202+
/// folder) in use by the app process (through the `CoreWebView2Environment` options
203+
/// used) is shared with other processes, these processes need to coordinate to
204+
/// handle the potential race condition on the use of the resources. E.g., if one
205+
/// app process tries to clear the user data folder, while other tries to recreate
206+
/// its WebViews on crash.
203207
///
204208
/// Note this is an event from the `ICoreWebView2Environment3` interface, not the
205209
/// `ICoreWebView2`. The difference between this `BrowserProcessExited` event and
206210
/// the `CoreWebView2`'s `ProcessFailed` event is that `BrowserProcessExited` is
207-
/// raised for any (expected and unexpected) **browser process** exits, while
208-
/// `ProcessFailed` is raised only for **unexpected** browser process exits, or for
209-
/// **render process** exits/unresponsiveness. To learn more about the WebView2
210-
/// Process Model, go to [Process model](https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/process-model).
211+
/// raised for any (expected and unexpected) **browser process** (along its
212+
/// associated processes) exits, while `ProcessFailed` is raised only for
213+
/// **unexpected** browser process exits, or for **render process**
214+
/// exits/unresponsiveness. To learn more about the WebView2 Process Model, go to
215+
/// [Process model](https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/process-model).
211216
///
212217
/// In the case the browser process crashes, both `BrowserProcessExited` and
213218
/// `ProcessFailed` events are raised, but the order is not guaranteed.
@@ -268,20 +273,22 @@ namespace Microsoft.Web.WebView2.Core
268273
/// been released.
269274
///
270275
/// All `CoreWebView2Environment` objects across different app processes that use
271-
/// the same browser process receive this event when the browser process exits.
272-
/// If the browser process (and therefore the user data folder) in use by the app
273-
/// process (through the `CoreWebView2Environment` options used) is shared with
274-
/// other processes, these processes need to coordinate to handle the potential race
275-
/// condition on the use of the resources. E.g., if one app process tries to clear
276-
/// the user data folder, while other tries to recreate its WebViews on crash.
276+
/// the same browser process receive this event when the browser process (and
277+
/// associated processes) exits. If the browser process (and therefore the user data
278+
/// folder) in use by the app process (through the `CoreWebView2Environment` options
279+
/// used) is shared with other processes, these processes need to coordinate to
280+
/// handle the potential race condition on the use of the resources. E.g., if one
281+
/// app process tries to clear the user data folder, while other tries to recreate
282+
/// its WebViews on crash.
277283
///
278-
/// Note this is an event from `CoreWebView2Environment`, not the
279-
/// `CoreWebView2`. The difference between this `BrowserProcessExited` event and
284+
/// Note this is an event from the `ICoreWebView2Environment3` interface, not the
285+
/// `ICoreWebView2`. The difference between this `BrowserProcessExited` event and
280286
/// the `CoreWebView2`'s `ProcessFailed` event is that `BrowserProcessExited` is
281-
/// raised for any (expected and unexpected) **browser process** exits, while
282-
/// `ProcessFailed` is raised only for **unexpected** browser process exits, or for
283-
/// **render process** exits/unresponsiveness. To learn more about the WebView2
284-
/// Process Model, go to [Process model](https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/process-model).
287+
/// raised for any (expected and unexpected) **browser process** (along its
288+
/// associated processes) exits, while `ProcessFailed` is raised only for
289+
/// **unexpected** browser process exits, or for **render process**
290+
/// exits/unresponsiveness. To learn more about the WebView2 Process Model, go to
291+
/// [Process model](https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/process-model).
285292
///
286293
/// In the case the browser process crashes, both `BrowserProcessExited` and
287294
/// `ProcessFailed` events are raised, but the order is not guaranteed.

0 commit comments

Comments
 (0)