Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
remopini opened this issue Oct 1, 2022 · 6 comments · Fixed by #13222
Closed

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

remopini opened this issue Oct 1, 2022 · 6 comments · Fixed by #13222
Assignees
Labels
area-controls-webview WebView fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! platform/windows 🪟 t/bug Something isn't working
Milestone

Comments

@remopini
Copy link

remopini commented Oct 1, 2022

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 remopini added the t/bug Something isn't working label Oct 1, 2022
@l4nk4b3l
Copy link

l4nk4b3l commented Oct 1, 2022

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.

@remopini
Copy link
Author

remopini commented Oct 2, 2022

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.

@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Oct 3, 2022
@jsuarezruiz
Copy link
Contributor

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

issue-10438

@remopini
Copy link
Author

remopini commented Oct 3, 2022

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.

@jsuarezruiz jsuarezruiz self-assigned this Oct 3, 2022
@jsuarezruiz
Copy link
Contributor

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 jsuarezruiz added this to the Backlog milestone Oct 3, 2022
@ghost
Copy link

ghost commented Oct 3, 2022

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.

@jfversluis jfversluis changed the title WebView Crashes WebView Crashes when Source.Html is updated more than once on Windows Oct 14, 2022
@jsuarezruiz jsuarezruiz self-assigned this Feb 9, 2023
@jsuarezruiz jsuarezruiz moved this from Todo to In Progress in MAUI SDK Ongoing Feb 9, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in MAUI SDK Ongoing Feb 14, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! label Feb 22, 2023
@samhouts samhouts modified the milestones: Backlog, 8.0-preview1 Feb 22, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Mar 24, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-webview WebView fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants