Bug 48090 - Java.Lang.StackOverflowError when using FormattedText inside ListView inside CarouselView
Summary: Java.Lang.StackOverflowError when using FormattedText inside ListView inside ...
Status: RESOLVED NOT_ON_ROADMAP
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: Other Other
: --- normal
Target Milestone: ---
Assignee: Jimmy [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2016-11-26 21:27 UTC by Dmitry
Modified: 2017-06-19 18:14 UTC (History)
5 users (show)

Tags: android, carouselview
Is this bug a regression?: ---
Last known good build:


Attachments
sample project (298.38 KB, application/x-zip-compressed)
2017-03-22 21:45 UTC, Jimmy [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_ON_ROADMAP

Description Dmitry 2016-11-26 21:27:31 UTC
Hello. I'm using Forms running application on Android. The following code issues an exception Java.Lang.StackOverflowError
Code behind:

public FormattedString CustomFormattedText
        {
            get
            {
                var output = new FormattedString();

                output.Spans.Add(new Span() { Text = WordText, FontSize = 24, ForegroundColor = Color.FromHex("#120A8F") });

/*
other spans (without them exception throwns as well)
*/

                return output;
            }
            set { }
        }

~~~~~~~~
XAML: 
<DataTemplate> <!-- I use it in as a carousel view's itemsource-->
<ListView HasUnevenRows="True" ItemsSource="{Binding CurrentWordWrappedList}">
              <ListView.ItemTemplate>
                <DataTemplate>
                  <ViewCell>
                    <StackLayout Orientation="Horizontal" HorizontalOptions="Fill">
                      <StackLayout Orientation="Vertical" HorizontalOptions="Start">
                        <Label FormattedText="{Binding CustomFormattedText}"/>
                      </StackLayout>
                    </StackLayout>
                  </ViewCell>
                </DataTemplate>
              </ListView.ItemTemplate>
            </ListView>
</DataTemplate>

CurrentWordWrappedList always contains only 1 element (since as it's a fiction), so I'm updating it this way:

CurrentWordWrappedList.Clear();
CurrentWordWrappedList.Add(value);

Then an exception throwns: Java.Lang.StackOverflowError
Comment 1 adrianknight89 2016-11-26 22:16:08 UTC
Can you post an actual repro?
Comment 2 Jimmy [MSFT] 2017-03-22 21:45:17 UTC
Created attachment 20692 [details]
sample project

I created a sample app based on the code provided in the description, but I was not able to reproduce this crash. 

If you are still experiencing this issue with the latest version of Forms and Forms.CarouselView, please attach a project that reproduces the issue so we can continue looking into this. Thanks!
Comment 3 Dmitry 2017-04-17 21:58:07 UTC
I reduced a number of nested layouts then but now I meet it again on 2.3.4.231, CarouselView 2.3.0-pre2 and can't reduce. I face it only on SDK 15 (HTC Desire dual sim u), with SDK 17 emulator works fine. 

<!-- (I need this structure of elements) -->
<Grid Grid.Row="0" Grid.Column="0" Grid.RowSpan="4">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition>
                    <RowDefinition.Height>
                        <OnIdiom x:TypeArguments="GridLength"
                            Phone="50"
                            Tablet="100"
                        />
                    </RowDefinition.Height>
                </RowDefinition>
            </Grid.RowDefinitions>

            <cv:CarouselView>
                <cv:CarouselView.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <ListView Grid.Row="0" HasUnevenRows="True" ItemsSource="{Binding Words}" >
                                <ListView.ItemTemplate>
                                    <DataTemplate>
                                        <ViewCell>
                                            <StackLayout>
                                                <Label FormattedText="{Binding CustomFormattedText}" />
                                            </StackLayout>
                                            
                                        </ViewCell>
                                    </DataTemplate>
                                </ListView.ItemTemplate>
                            </ListView>
                        </Grid>
                        
                    </DataTemplate>
                </cv:CarouselView.ItemTemplate>
            </cv:CarouselView>
        </Grid>


----

public FormattedString CustomFormattedText
        {
            get
            {
                var output = new FormattedString();

                output.Spans.Add(new Span()
                {
                    Text = WordText,
                    FontSize =
                        Device.Idiom == TargetIdiom.Phone ?
                        24
                        : 48,
                    ForegroundColor = Color.FromHex("#120A8F")
                });

                if (Transcription != null && Transcription.Length >= 2)
                {
                    output.Spans.Add(new Span() { Text = Environment.NewLine });
                    output.Spans.Add(new Span()
                    {
                        Text = Transcription,
                        FontSize =
                                Device.Idiom == TargetIdiom.Phone ?
                                16
                                : 32,
                        FontFamily = "arial",
                    });
                }



                return output;
            }
            set { }
        }

Exception:

04-18 00:54:08.255 E/AndroidRuntime( 2195): FATAL EXCEPTION: main
04-18 00:54:08.255 E/AndroidRuntime( 2195): java.lang.StackOverflowError
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.text.TextLine.drawTextRun(TextLine.java:1067)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.text.TextLine.handleText(TextLine.java:791)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.text.TextLine.handleRun(TextLine.java:1034)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.text.TextLine.drawRun(TextLine.java:397)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.text.TextLine.draw(TextLine.java:195)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.text.Layout.draw(Layout.java:430)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.text.BoringLayout.draw(BoringLayout.java:409)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.widget.TextView.onDraw(TextView.java:5273)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.draw(View.java:11014)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10444)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2788)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10442)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2788)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10442)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2788)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10442)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2788)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10442)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.widget.ListView.drawChild(ListView.java:3499)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2788)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.widget.AbsListView.dispatchDraw(AbsListView.java:2134)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.widget.ListView.dispatchDraw(ListView.java:3489)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.draw(View.java:11017)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.widget.AbsListView.draw(AbsListView.java:3453)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.widget.ListView.draw(ListView.java:4200)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10444)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2795)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.draw(View.java:11017)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10444)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2788)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10442)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2788)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10442)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.support.v7.widget.RecyclerView.drawChild(RecyclerView.java:3838)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2788)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.draw(View.java:11017)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.support.v7.widget.RecyclerView.draw(RecyclerView.java:3308)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10444)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2788)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10442)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2788)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.draw(View.java:11017)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10444)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2788)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.draw(View.java:11017)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10444)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2788)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.draw(View.java:11017)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10444)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2788)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10442)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2788)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10442)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.drawChild(ViewGroup.java:3149)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2788)
04-18 00:54:08.255 E/AndroidRuntime( 2195): 	at android.view.View.getDisplayList(View.java:10442)
04-18 00:54:14.331 D/Mono    ( 2195): [0x3c905a8] worker finishing
Comment 4 Dmitry 2017-04-17 22:05:11 UTC
Fast fix: 
<cv:CarouselView Grid.Row="0" Grid.Column="0">

There's also an element at row 1 but commenting out gave no result.
Comment 5 Dmitry 2017-04-17 22:08:21 UTC
There also no this exception when Label is out of StackLayout/Grid/etc:

<ViewCell>
                                                <Label FormattedText="{Binding CustomFormattedText}" />
                                            
                                        </ViewCell>

Code above works fine, but I need my label wrapped.
Comment 6 Chris Hardy [MSFT] 2017-06-19 17:22:26 UTC
Marking as Confirmed with the extra information shared for Jimmy to dig in further
Comment 7 Samantha Houts [MSFT] 2017-06-19 18:14:26 UTC
This issue is not present in the newly proposed version of CarouselView. Closing this issue. Thank you!
	
https://github.com/xamarin/Xamarin.Forms/pull/853