maui icon indicating copy to clipboard operation
maui copied to clipboard

WebView Crashes when `Source.Html` is updated more than once on Windows

Open remopini opened this issue 3 years ago • 6 comments

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

  1. Create a new Maui application with a button and a webview on it.
  2. Assign a HtmlWebViewSource to the webview.
  3. Add an event handler that fires when the button is pressed.
  4. Have that event handler modify the Html property of the HtmlWebViewSource twice.
  5. 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

remopini avatar Oct 01 '22 10:10 remopini

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.

l4nk4b3l avatar Oct 01 '22 21:10 l4nk4b3l

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.

remopini avatar Oct 02 '22 08:10 remopini

Cannot reproduce the issue in Windows 10 21H2. Will test again in another machine with Windows 11.

issue-10438

jsuarezruiz avatar Oct 03 '22 08:10 jsuarezruiz

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.

remopini avatar Oct 03 '22 08:10 remopini

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.

jsuarezruiz avatar Oct 03 '22 10:10 jsuarezruiz

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.

ghost avatar Oct 03 '22 10:10 ghost