diff --git a/docs/user-interface/controls/blazorwebview.md b/docs/user-interface/controls/blazorwebview.md index 534460bc2..0edd2ed7f 100644 --- a/docs/user-interface/controls/blazorwebview.md +++ b/docs/user-interface/controls/blazorwebview.md @@ -1,7 +1,7 @@ --- title: "Host a Blazor web app in a .NET MAUI app using BlazorWebView" description: "The .NET MAUI BlazorWebView control enables you to host a Blazor web app in your .NET MAUI app, and integrate the app with device features." -ms.date: 10/01/2024 +ms.date: 11/13/2024 --- # Host a Blazor web app in a .NET MAUI app using BlazorWebView @@ -218,20 +218,20 @@ To play inline video in a Blazor hybrid app on iOS, in a performs async-over-sync disposal, which means that it blocks the thread until the async disposal is complete. However, this can cause deadlocks if the disposal needs to run code on the same thread (because the thread is blocked while waiting). +By default, fires and forgets the async disposal of the underlying `WebViewManager`. This reduces the potential for disposal deadlocks to occur on Android. -If you encounter hangs on Android with you should enable an switch in the `CreateMauiApp` method in *MauiProgram.cs*: +> [!WARNING] +> This fire-and-forget default behavior means that disposal can return before all objects are disposed, which can cause behavioral changes in your app. The items that are disposed are partially Blazor's own internal types, but also app-defined types such as scoped services used within the portion of your app. + +To opt out of this behavior, you should configure your app to block on dispose via an switch in the `CreateMauiApp` method in your `MauiProgram` class: ```csharp -AppContext.SetSwitch("BlazorWebView.AndroidFireAndForgetAsync", true); +AppContext.SetSwitch("BlazorWebView.AndroidFireAndForgetAsync", false); ``` -This switch enables to fire and forget the async disposal that occurs, and as a result fixes the majority of the disposal deadlocks that occur on Android. - -> [!WARNING] -> Enabling this switch means that disposal can return before all objects are disposed, which can cause behavioral changes in your app. The items that are disposed are partially Blazor's own internal types, but also app-defined types such as scoped services used within the portion of your app. +If your app is configured to block on dispose via this switch, performs async-over-sync disposal, which means that it blocks the thread until the async disposal is complete. However, this can cause deadlocks if the disposal needs to run code on the same thread (because the thread is blocked while waiting). ## Host content using the legacy behavior on iOS and Mac Catalyst diff --git a/docs/whats-new/dotnet-9.md b/docs/whats-new/dotnet-9.md index e8c4b9474..6a87e5574 100644 --- a/docs/whats-new/dotnet-9.md +++ b/docs/whats-new/dotnet-9.md @@ -153,13 +153,18 @@ To opt into using the `0.0.0.1` address, add the following code to the `CreateMa AppContext.SetSwitch("BlazorWebView.AppHostAddressAlways0000", true); ``` -If you encounter hangs on Android with you should enable an switch in the `CreateMauiApp` method in your `MauiProgram` class: +By default, now fires and forgets the async disposal of the underlying `WebViewManager`. This reduces the potential for disposal deadlocks to occur on Android. + +> [!WARNING] +> This fire-and-forget default behavior means that disposal can return before all objects are disposed, which can cause behavioral changes in your app. The items that are disposed are partially Blazor's own internal types, but also app-defined types such as scoped services used within the portion of your app. + +To opt out of this behavior, you should configure your app to block on dispose via an switch in the `CreateMauiApp` method in your `MauiProgram` class: ```csharp -AppContext.SetSwitch("BlazorWebView.AndroidFireAndForgetAsync", true); +AppContext.SetSwitch("BlazorWebView.AndroidFireAndForgetAsync", false); ``` -This switch enables to fire and forget the async disposal that occurs, and as a result fixes the majority of the disposal deadlocks that occur on Android. For more information, see [Fix disposal deadlocks on Android](~/user-interface/controls/blazorwebview.md#fix-disposal-deadlocks-on-android). +If your app is configured to block on dispose via this switch, performs async-over-sync disposal, which means that it blocks the thread until the async disposal is complete. However, this can cause deadlocks if the disposal needs to run code on the same thread (because the thread is blocked while waiting). ### Buttons on iOS