2
votes

I'm facing to an issue with Xamarin.Forms and more particulary with TabbedPage on Android.

I have created a TabbedPage that contains 4 ContentPage. Each ContentPage contains a ListView with a custom ItemTemplate (more than 50 lines in XAML). It's working fine on iOS but not on Android and I received this exception :

Java.Lang.StackOverflowError: 
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
  at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x000a7] in /Users/builder/data/lanes/3819/96c7ba6c/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:12083
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00068] in /Users/builder/data/lanes/3819/96c7ba6c/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:31
  at Android.Views.View.Draw (Android.Graphics.Canvas canvas) [0x0002c] in /Users/builder/data/lanes/3819/96c7ba6c/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Views.View.cs:12837
  at Xamarin.Forms.Platform.Android.ScrollViewRenderer.Draw (Android.Graphics.Canvas canvas) [0x0000d] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ScrollViewRenderer.cs:99
  at Android.Views.View.n_Draw_Landroid_graphics_Canvas_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_canvas) [0x00011] in /Users/builder/data/lanes/3819/96c7ba6c/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Views.View.cs:12825
  at at (wrapper dynamic-method) System.Object:75413b68-d1a4-4864-b7a4-6d3fd2662bd8 (intptr,intptr,intptr)
  at java.lang.StackOverflowError
  at at android.graphics.Paint.getTextRunAdvances(Paint.java:2221)
  at at android.text.TextLine.handleText(TextLine.java:815)
  at at android.text.TextLine.handleRun(TextLine.java:970)
  at at android.text.TextLine.measureRun(TextLine.java:482)
  at at android.text.TextLine.measure(TextLine.java:361)
  at at android.text.TextLine.metrics(TextLine.java:335)
  at at android.text.Layout.getLineExtent(Layout.java:1001)
  at at android.text.Layout.drawText(Layout.java:332)
  at at android.text.Layout.draw(Layout.java:208)
  at at android.text.BoringLayout.draw(BoringLayout.java:403)
  at at android.widget.TextView.onDraw(TextView.java:6286)
  at at android.view.View.draw(View.java:15312)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.widget.ListView.drawChild(ListView.java:3403)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.widget.AbsListView.dispatchDraw(AbsListView.java:2931)
  at at android.widget.ListView.dispatchDraw(ListView.java:3398)
  at at android.view.View.draw(View.java:15315)
  at at android.widget.AbsListView.draw(AbsListView.java:5153)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3151)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.widget.FrameLayout.draw(FrameLayout.java:472)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.widget.FrameLayout.draw(FrameLayout.java:472)
  at at android.widget.ScrollView.draw(ScrollView.java:2156)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ScrollViewRenderer.n_draw(Native Method)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ScrollViewRenderer.draw(ScrollViewRenderer.java:59)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3151)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.support.v4.view.ViewPager.draw(ViewPager.java:2336)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.widget.FrameLayout.draw(FrameLayout.java:472)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.getDisplayList(View.java:14201)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.View.draw(View.java:15026)
  at at android.view.ViewGroup.drawChild(ViewGroup.java:3307)
  at at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3144)
  at at android.view.View.draw(View.java:15315)
  at at android.widget.FrameLayout.draw(FrameLayout.java:472)
  at at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2540)
  at at android.view.View.getDisplayList(View.java:14206)
  at at android.view.View.getDisplayList(View.java:14248)
  at at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1570)
  at at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1449)
  at at android.view.ViewRootImpl.draw(ViewRootImpl.java:2667)
  at at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2533)
  at at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2107)
  at at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1200)
  at at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6401)
  at at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
  at at android.view.Choreographer.doCallbacks(Choreographer.java:603)
  at at android.view.Choreographer.doFrame(Choreographer.java:573)
  at at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
  at at android.os.Handler.handleCallback(Handler.java:733)
  at at android.os.Handler.dispatchMessage(Handler.java:95)
  at at android.os.Looper.loop(Looper.java:157)
  at at android.app.ActivityThread.main(ActivityThread.java:5335)
  at at java.lang.reflect.Method.invokeNative(Native Method)
  at at java.lang.reflect.Method.invoke(Method.java:515)
  at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
  at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
  at at dalvik.system.NativeStart.main(Native Method)

After some researches on Google I found this same issue https://forums.xamarin.com/discussion/48144/stackoverflowerror-on-android but the workaround could not be applied in my case (I can't reduce the number of line of my itemtemplate). However, I'm not sure that the source of the issue is the number of elements in the ItemTemplate because the same ContentPage works fine in a MasterDetailPage on Android

If I cannot use the TabbedPage, do you know a component/sample that I can use to create a TabBar in Xamarin.Forms.

Thank you in advance for your help. Regards. Olivier.

1
What device/simulator you are testing on? Can you put your code somewhere, so we can try to reproduce?Yuri S
@YuriS Thank you for your answer. I found my issue, it appears when we create a TabbedPage inside a NavigationPage. I think that we cannot create navigation page that contains a TabbedPage. It works on iOS but not Android. It's preferable to create a NavigationPage for each child page of my TabbedPage. Thxuser1317878
i was having this same error and fixed it by reducing the number of layout elements on my listview itemtemplate. i suggest using grids with rowspan and columnspan to make your layouts more efficient.Lucas Moura Veloso

1 Answers

1
votes

I had the same problem when I had ListView wrapped in ScrollView at TabbedPage. You need to remove ScrollView from this layout. because ListView has its own inner scrolling