Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

View hierarchy in android leeds to StackOverflowError

$
0
0

Hello,

we are currently testing our Xamarin.Forms application on older android devices (with < 1GB Ram).

On lot's of these devices (which are still very common in our target countries) the app crashes when displaying a ListView.

The source of this error seems to be a large view hierarchy:

java.lang.StackOverflowError:
at android.view.GLES20Canvas.nGetClipBounds(Native Method: )
at android.view.GLES20Canvas.getClipBounds(GLES20Canvas.java: 487)
at android.text.Layout.draw(Layout.java: 205)
at android.text.BoringLayout.draw(BoringLayout.java: 409)
at android.widget.TextView.onDraw(TextView.java: 5257)
at android.view.View.draw(View.java: 11071)
at android.view.View.getDisplayList(View.java: 10462)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)
at android.view.View.getDisplayList(View.java: 10460)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)
at android.view.View.draw(View.java: 11074)
at android.view.View.getDisplayList(View.java: 10462)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)
at android.view.View.getDisplayList(View.java: 10460)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)
at android.view.View.getDisplayList(View.java: 10460)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.widget.ListView.drawChild(ListView.java: 3271)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)
at android.widget.AbsListView.dispatchDraw(AbsListView.java: 2105)
at android.widget.ListView.dispatchDraw(ListView.java: 3266)
at android.view.View.draw(View.java: 11074)
at android.widget.AbsListView.draw(AbsListView.java: 3411)
at android.view.View.getDisplayList(View.java: 10462)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2504)
at android.view.View.draw(View.java: 11074)
at android.view.View.getDisplayList(View.java: 10462)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)
at android.view.View.draw(View.java: 11074)
at android.view.View.getDisplayList(View.java: 10462)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)
at android.view.View.draw(View.java: 11074)
at android.view.View.getDisplayList(View.java: 10462)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)
at android.view.View.draw(View.java: 11074)
at android.view.View.getDisplayList(View.java: 10462)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)
at android.view.View.getDisplayList(View.java: 10460)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)
at android.view.View.draw(View.java: 11074)
at android.view.View.getDisplayList(View.java: 10462)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)
at android.view.View.draw(View.java: 11074)
at android.view.View.getDisplayList(View.java: 10462)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)
at android.view.View.draw(View.java: 11074)
at android.view.View.getDisplayList(View.java: 10462)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)
at android.view.View.getDisplayList(View.java: 10460)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java: 1229)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)
at android.view.View.getDisplayList(View.java: 10460)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)
at android.view.View.getDisplayList(View.java: 10460)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2497)

Do you have any ideas how to circumvent this problem with Xamarin.Forms?

Even this simple test (as illustrated in the image has a depth of 14).

According to stackoverflow this could cause these exceptions (http://stackoverflow.com/questions/9946368/stackoverflow-caused-by-nested-views)

This is the sample code I used, how could that simple code create such a deep nesting of views?

 this.MainPage =
            new NavigationPage(
                new ContentPage
                    {
                        Content =
                            new ListView
                                {
                                    IsPullToRefreshEnabled = true,
                                    VerticalOptions = LayoutOptions.FillAndExpand,
                                    HorizontalOptions = LayoutOptions.FillAndExpand,
                                    Header = "Placeholder",
                                    HeaderTemplate = new DataTemplate(() => new Label { Text = "Test" } ),
                                    ItemsSource = new List<string> { "1", "2" },
                                    ItemTemplate =
                                        new DataTemplate(
                                        () => new ViewCell { View = new StackLayout { Children = { new Label { Text = "Test" } } } })
                                }
                    });

Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>