xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] [Android] Upgrade from version 4.8 to 5.0 breaks Label Texttype Html Text rendering #13387

Open Moreno-Borsalino opened 3 years ago

Moreno-Borsalino commented 3 years ago

Description

I upgraded an Android App from version 4.8 to 5.0 and I had problem on one page very simple showing only a Label with Html Text inside. With version 5.0 it shows only the first part of the text by completely cutting off the last part. However, with version 4.8 there were no problems. The text is about 3535 characters long and contains only some <h2> and <br> tags.

Steps to Reproduce

The ContentPage contains only a Label inside a ScrolView element:

<ScrollView Margin="10" VerticalScrollBarVisibility="Never"> <StackLayout Orientation="Vertical"> <Label x:Name="PrivacyLabel" TextType="Html" /> </StackLayout> </ScrollView>

The Text is added in code behind in the OnAppearing method because it changes depending on languages localization. The text is about 3535 characters long and contains only some <h2> and <br> tags.

Expected Behavior

All the text is showed with the correct HTML formatting

Actual Behavior

With version 5.0 the last part of the text is missing but if I rotate the smartphone horizontally then the missing part of the text also appears. If I go back vertically you can see all the text. But if I go back and then return to the same page the initial problem returns, the last part of the text is missing

Basic Information

Has anyone else had the same problem?

rachelkang commented 3 years ago

Hi, @Moreno-Borsalino - thanks so much for submitting this issue! I tried to reproduce what you described, but unfortunately wasn't able to. Would you modify this sample project to reflect the issue you're experiencing? Issue13387.zip

And if you haven't already, please try updating to the latest version of XF 5.0 in your own project!

Moreno-Borsalino commented 3 years ago

Hi Rachel, I am sending you the updated project to reproduce the bug. Respect your project I added the long string inside resources and added NotificationPage to have a second page to jump in and get the wrong behavior. I changed also to Android 10. I tested in an emulator in Visual Studio 2019. The emulator is based on device Pixel 3a (+ Store), CPU x86_64 and operating system Android Q 10.0 - API 29. Attached you can find an emulator screenshot with wrong behavior; you can see the missing part of text at the bottom of the screen. If you need more information please write to me again. Best Regards Moreno Borsalino

Da: Rachel Kangmailto:notifications@github.com Inviato: mercoledì 20 gennaio 2021 20:28 A: xamarin/Xamarin.Formsmailto:Xamarin.Forms@noreply.github.com Cc: Moreno Borsalinomailto:borsalino@hotmail.it; Mentionmailto:mention@noreply.github.com Oggetto: Re: [xamarin/Xamarin.Forms] [Bug] [Android] Upgrade from version 4.8 to 5.0 breaks Label Texttype Html Text rendering (#13387)

Hi, @Moreno-Borsalinohttps://github.com/Moreno-Borsalino - thanks so much for submitting this issue! I tried to reproduce what you described, but unfortunately wasn't able to. Would you modify this sample project to reflect the issue you're experiencing? Issue13387.ziphttps://github.com/xamarin/Xamarin.Forms/files/5844792/Issue13387.zip

And if you haven't already, please try updating to the latest version of XF 5.0 in your own project!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/xamarin/Xamarin.Forms/issues/13387#issuecomment-763879572, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHTSTTWKE4R5RBY5SY3JASLS24VG5ANCNFSM4WAU2V4Q.

Moreno-Borsalino commented 3 years ago

Hi Rachel, I don't understand if you got the attached files to my email. I sending you again the files with the updated project to reproduce the bug. Respect your project I added the long string inside resources and added NotificationPage to have a second page to jump in and get the wrong behavior. I changed also to Android 10. I tested in an emulator in Visual Studio 2019. The emulator is based on device Pixel 3a (+ Store), CPU x86_64 and operating system Android Q 10.0 - API 29. Attached you can find an emulator screenshot with wrong behavior; you can see the missing part of text at the bottom of the screen. Issue13387 updated.zip Issue13387 behavior

rachelkang commented 3 years ago

@Moreno-Borsalino got it - thanks for elaborating and sharing the details! I'm able to see it now :)

Moreno-Borsalino commented 3 years ago

@rachelkang I am happy to be able to make a small contribution to this project :-)

hartez commented 3 years ago

The break seems to be between 5.0.0 pre1 and pre2.

kazo0 commented 3 years ago

Can confirm this is happening in my application as well. Rotating the device does cause the text to be displayed. What's weird is that the Label/ScrollView/Grid seems to be measured fully since I am able to scroll the proper distance, but there's just empty space where there should be text.

It doesn't happen all of the time but I find that I can repro it around 80% of the time by switching apps (not killing the app) to the Settings app, increasing the system font size, then switching back to my app and observing the now larger text is clipped.

XAML:

<ScrollView>
    <Grid>
        <StackLayout Margin="20">
            <Label AutomationId="{x:Static constants:AutomationConstants.DR_Reflection_Title}"
                    FontSize="Title"
                    HorizontalTextAlignment="Center"
                    Text="{Binding DailyReflection.Title}"
                    TextType="Html" />
            <Label Margin="0,20,0,0"
                    AutomationId="{x:Static constants:AutomationConstants.DR_Reflection_Quote}"
                    FontAttributes="Italic"
                    FontSize="Body"
                    HorizontalTextAlignment="Center"
                    Text="{Binding DailyReflection.Reading}"
                    TextType="Html" />
            <Label AutomationId="{x:Static constants:AutomationConstants.DR_Reflection_QuoteSource}" Text="{Binding DailyReflection.Source, StringFormat='— {0}'}" />
            <Label Margin="0,20,0,0"
                    AutomationId="{x:Static constants:AutomationConstants.DR_Reflection_Thought}"
                    FontSize="Body"
                    Text="{Binding DailyReflection.Thought}"
                    TextType="Html" />
            <Label AutomationId="{x:Static constants:AutomationConstants.DR_Reflection_Copyright}"
                    FontSize="Caption"
                    Text="From the book &lt;i&gt;Daily Reflections&lt;/i&gt;&lt;br&gt; Copyright © 1990 by Alcoholics Anonymous World Services, Inc."
                    TextType="Html" />
        </StackLayout>
    </Grid>
</ScrollView>

Actual: textcut

Expected: textcut2

Moreno-Borsalino commented 3 years ago

Kazo0 you are welcome in this forgotten thread and I am happy to know you confirm this sneaky bug. it is now from January that I wait for a solution but until now no one has taken charge of solving the bug. I launch an appeal to all the guys in the team; please, is there anyone who would like to finally solve this bug? I thank you with all my heart

AlleSchonWeg commented 3 years ago

You could test https://github.com/baskren/Forms9Patch Label

jfversluis commented 3 years ago

in this forgotten thread

Nope, we're still here!

Moreno-Borsalino commented 3 years ago

Nope, we're still here!

Hi Gerald, I'm glad to see that something is moving. Thank you. I marked in red the date of October 13 on the calendar

jfversluis commented 3 years ago

I was afraid you were going to say that. Please don't get your hopes up that it's fixed by then. I am creating project board kind of as todo lists and moving unfinished issues over to the next one. It's on our list now and we're getting to it, but I can't give you any dates unfortunately.

Moreno-Borsalino commented 3 years ago

I was afraid you were going to say that.

Don't worry Gerald, I understand that there are many bugs to be solved and many much more important than this. I have waited a long time and I can still wait. Furthermore, we are in a phase in which it is not clear whether to wait for the evolution of Xamarin or to start looking at MAUI. So I think waiting a little longer can help bring clarity in which direction to go for the future.

jsuarezruiz commented 3 years ago

@Moreno-Borsalino Could you share the latest exactly version where it was working?. I think is more related with ScrollView and layouts than maybe with the Html text implementation but, first I want to search between code changes to see possible causes.

Moreno-Borsalino commented 3 years ago

@Moreno-Borsalino Could you share the latest exactly version where it was working?.

@jsuarezruiz Hi Javier, here it is a working version with xamarin.forms version 4.8.0.1821 Issue13387 this run ok.zip

Moreno-Borsalino commented 2 years ago

I found a trick to fix this bug and finally be able to upgrade to version 5 of Xamarin.Forms. I deleted the code in the OnAppearing method in the code behind which updates the page Title and the Text field of the Label. And I added reading data directly into the XAML code in the following way:

<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:resources="clr-namespace:Pws4.Resx;assembly=Pws4" x:Class="Pws4.View.PrivacyStatementPage" Title="{x:Static resources:AppResources.PrivacyStatementTitle}"> <ContentPage.Content> <ScrollView Margin="10" VerticalScrollBarVisibility="Never"> <StackLayout Orientation="Vertical"> <Label x:Name="PrivacyLabel" TextType="Html" Text="{x:Static resources:AppResources.PrivacyStatementPrivacyLabelText}" /> </StackLayout> </ScrollView> </ContentPage.Content> </ContentPage>

jfversluis commented 2 years ago

Great, thanks for sharing the workaround!