maui
maui copied to clipboard
WebView Crashes when `Source.Html` is updated more than once on Windows
Description
When updating the Html property of a source for a WebView twice, there's an unhandled win32 exception.
Example:
MainPage.xaml:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="WebViewTest.MainPage">
<VerticalStackLayout>
<Button x:Name="btn" WidthRequest="400" HeightRequest="50" Text="Go" Clicked="btn_Clicked" />
<WebView x:Name="web" WidthRequest="400" HeightRequest="400" Background="blue" />
</VerticalStackLayout>
</ContentPage>
MainPage.xaml.cs:
namespace WebViewTest;
public partial class MainPage : ContentPage
{
HtmlWebViewSource src = new();
public MainPage()
{
InitializeComponent();
web.Source = src;
}
private void btn_Clicked(object sender, EventArgs e)
{
Random rnd = new();
src.Html += $"<h1>Hello World {rnd.Next()}!</h1><br>";
//src.Html += $"<h1>Hello World {rnd.Next()}!</h1><br>"; // uncommenting this, crashes the program
//web.Reload(); // not needed
}
}
- Hitting the button as many times as you want works fine
- Uncommenting the 2nd src.Html = ... line causes a crash.
dotnet --version 6.0.401 (the latest VS.NET 2022 seems to offer)
Steps to Reproduce
- Create a new Maui application with a button and a webview on it.
- Assign a HtmlWebViewSource to the webview.
- Add an event handler that fires when the button is pressed.
- Have that event handler modify the Html property of the HtmlWebViewSource twice.
- Watch it crash...
Link to public reproduction project repository
https://github.com/remopini/WebViewTest
Version with bug
Unknown/Other (please specify)
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
Win 11 with all current updates
Did you find any workaround?
No
Relevant log output
No response
As far as i can tell as soon as the HtmlWebViewSource.Html property is updated the WebView will start refreshing. Calling reload is not necessary.
As far as i can tell as soon as the HtmlWebViewSource.Html property is updated the WebView will start refreshing. Calling reload is not necessary.
That seems to be true, thx for the tip. However having that statement there (or not) doesn't change the problem.
Cannot reproduce the issue in Windows 10 21H2. Will test again in another machine with Windows 11.

It doesn't look like you uncommented the 2nd line (it only crashed when you do that). It should add TWO entries with every click.
It doesn't look like you uncommented the 2nd line (it only crashed when you do that). It should add TWO entries with every click.
Right, can reproduce it.
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.