dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.98k stars 1.72k forks source link

Flickering Issue When Toggling WebView Visibility in Grid Layout on Android #24113

Open kellymmcd opened 1 month ago

kellymmcd commented 1 month ago

Description

In Android when changing the visibility of a WebView within a grid I'm getting an issue where the elements underneath the grid start flickering as seen in video below.

https://github.com/user-attachments/assets/12dafdd7-398b-448b-9b7e-821bfa1d8cc5

Steps to Reproduce

  1. Create a new .NET MAUI app.
  2. Add the following XAML code in MainPage.xaml:

    
    <ScrollView>
    <Grid RowDefinitions="50,Auto,185,40"
        Padding="30,0">
        <Button
            Grid.Row="0"
            Text="Click me" 
            Clicked="OnClicked"
            HorizontalOptions="Fill" />
        <WebView
               x:Name="webView"
               IsVisible="False"
               Grid.Row="1">
            <WebView.Source>
                <HtmlWebViewSource>
                    <HtmlWebViewSource.Html>
                        <![CDATA[
                        <HTML>
                        <BODY>
                        <H1>.NET MAUI</H1>
                        <P>Welcome to WebView.</P>
                        </BODY>
                        </HTML>
                        ]]>
                    </HtmlWebViewSource.Html>
                </HtmlWebViewSource>
            </WebView.Source>
        </WebView>
        <Image
             Grid.Row="2"
             Source="dotnet_bot.png"
             HeightRequest="185"
             Aspect="AspectFit"
             SemanticProperties.Description="dot net bot in a race car number eight" />
    
        <Label
             Grid.Row="3"
             Text="Hello, World!"
             Style="{StaticResource Headline}"
             SemanticProperties.HeadingLevel="Level1" />
    </Grid>
    </ScrollView>

3. In the code-behind (MainPage.xaml.cs), add the following method:

private void OnClicked(object sender, EventArgs e) { webView.IsVisible = !webView.IsVisible; }


4. Run the app on a Android physical device or an emulator
5. Click the button to toggle the WebView visibility on and off.

### Link to public reproduction project repository

_No response_

### Version with bug

8.0.80 SR8

### Is this a regression from previous behavior?

Not sure, did not test other versions

### Last version that worked well

Unknown/Other

### Affected platforms

Android

### Affected platform versions

_No response_

### Did you find any workaround?

Setting a height request on the WebView prevents this from happening. However in my scenario I don't know the height of the contents in the WebView to set this. 

### Relevant log output

_No response_
github-actions[bot] commented 1 month ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

ninachen03 commented 1 month ago

Updated result Verified it again on latest 17.12.0 Preview 1.0 (8.0.80&8.0.71&8.0.61&8.0.3) and also repro in build 17.11.0 NET 7 MauiApp29.zip

PureWeen commented 3 weeks ago

@ninachen03 can you validate this one again against older versions of MAUI?

I've tested back to 8.0.60 and I'm still seeing the same issue mentioned

ninachen03 commented 3 weeks ago

@PureWeen I verified it again on latest 17.12.0 Preview 1.0 (8.0.80&8.0.71&8.0.61&8.0.3) and also repro in build 17.11.0 NET 7 SDK. 24113