StackOverflowError on Android

The same application works fine on Windows Phone, but throws error on Android.

Stack overflow on call to interp (req=68 top=0x56c51000 cur=0x56c4d33c size=16384 Ljava/lang/ref/FinalizerReference;.add)
threadid=1: stack overflow on call to Ljava/lang/ref/FinalizerReference;.add:VL
 UNHANDLED EXCEPTION:
 Java.Lang.StackOverflowError: Exception of type 'Java.Lang.StackOverflowError' was thrown.
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x00078>
 at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue*) <IL 0x0008a, 0x0034f>
 at Android.Views.View.Draw (Android.Graphics.Canvas) <IL 0x00092, 0x003d3>
 at Xamarin.Forms.Platform.Android.ScrollViewRenderer.Draw (Android.Graphics.Canvas) <IL 0x0000f, 0x000af>
    at android.util.Synchroni08-13 12:45:04.726 I/MonoDroid(19764): at Android.Views.View.n_Draw_Landroid_graphics_Canvas_ (intptr,intptr,intptr) <IL 0x00013, 0x000ef>
at (wrapper dynamic-method) object.352bcf4b-875e-4ceb-abab-c504c1ec3d50 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
  --- End of managed exception stack trace ---
java.lang.StackOverflowError
    at android.graphics.Canvas$CanvasFinalizer.<init>(Canvas.java:94)
    at android.graphics.Canvas.<init>(Canvas.java:119)
    at android.view.HardwareCanvas.<init>(HardwareCanvas.java:29)
    at android.view.GLES20Canvas.<init>(GLES20Canvas.java:102)
    at android.view.GLES20RecordingCanvas.<init>(GLES20RecordingCanvas.java:62)
    at android.view.GLES20RecordingCanvas.<init>(GLES20RecordingCanvas.java:38)

This code works.

var lblName = new Label {TextColor = Color.FromHex("7F7E7E")};

This code throws exception.

var lblName = new Label {TextColor = Color.FromHex("7F7E7E")};
lblName.Text = "123";

This label is located in the ListView.ItemTemplate

Answers

  • More details. At some android devices the app works fine (galaxy note, htc one), but it fails on Sony Xperia.

  • RenaudLaloireRenaudLaloire BEUniversity ✭✭

    I have the same error on my app : same as you, it happens in a ListView.ItemTemplate ... It worked before I updated to the latest stable Xamarin. I have a Galaxy S3 duo.

  • RenaudLaloireRenaudLaloire BEUniversity ✭✭

    Error log:

    UNHANDLED EXCEPTION: 08-14 17:08:02.795 I/MonoDroid(18133): Java.Lang.StackOverflowError: Exception of type 'Java.Lang.StackOverflowError' was thrown. 08-14 17:08:02.795 I/MonoDroid(18133): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x00078> 08-14 17:08:02.795 I/MonoDroid(18133): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue*) [0x00084] in /Users/builder/data/lanes/1879/5f55a9ef/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1029 08-14 17:08:02.795 I/MonoDroid(18133): at Android.Views.View.Draw (Android.Graphics.Canvas) [0x00070] in /Users/builder/data/lanes/1879/5f55a9ef/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Views.View.cs:13390 08-14 17:08:02.795 I/MonoDroid(18133): at Xamarin.Forms.Platform.Android.ScrollViewRenderer.Draw (Android.Graphics.Canvas) <IL 0x0000f, 0x000af> 08-14 17:08:02.795 I/MonoDroid(18133): at Android.Views.View.n_Draw_Landroid_graphics_Canvas_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/1879/5f55a9ef/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Views.View.cs:13372 08-14 17:08:02.795 I/MonoDroid(18133): at (wrapper dynamic-method) object.a4c15a38-5fcf-4c1d-9ad3-ef4d83bb7b76 (intptr,intptr,intptr) <IL 0x00017, 0x00043> 08-14 17:08:02.795 I/MonoDroid(18133): --- End of managed exception stack trace --- 08-14 17:08:02.795 I/MonoDroid(18133): java.lang.StackOverflowError 08-14 17:08:02.795 I/MonoDroid(18133): at android.view.HardwareRenderer.isAvailable(HardwareRenderer.java:258) 08-14 17:08:02.795 I/MonoDroid(18133): at android.view.View.onCreateDrawableState(View.java:16081) 08-14 17:08:02.795 I/MonoDroid(18133): at android.widget.TextView.onCreateDrawableState(TextView.java:6330) 08-14 17:08:02.795 I/MonoDroid(18133): at android.view.View.getDrawableState(View.java:16043) 08-14 17:08:02.795 I/MonoDroid(18133): at android.widget.TextView.onDraw(TextView.java:6546)

  • RenaudLaloireRenaudLaloire BEUniversity ✭✭

    As a temporary fix, I just reduced the number of XAML elements in my ItemTemplate (I had more than 25), it just worked. If I re-add elements (even simple

    It seems that the ItemTemplate does not accept too many elements and if so, a StackOverflowError is raised.

  • Confirming. The number of elements and maybe the nesting level influence the app behavior. Do not now whether it is Xamarin or Android bug.

  • SunnyKhan.3452SunnyKhan.3452 USMember ✭✭

    Hello guys, I am having below exception when I try to change the change pages from MasterDetailsPage. This exception is mainly occurring on Samasung. Can someone give a solution or a reason for this? It is working fine on all other devices but Samsung Android Version 4.0.4.

    Unhandled Exception:

    Java.Lang.StackOverflowError:

    04-13 11:26:07.400 D/Mono (10973): [0x2202528] hill climbing, change max number of threads 3
    04-13 11:26:07.430 E/AndroidRuntime(10973): FATAL EXCEPTION: main
    04-13 11:26:07.430 E/AndroidRuntime(10973): java.lang.StackOverflowError
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.draw(View.java:11180)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10616)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.draw(View.java:11180)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10616)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10614)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10614)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10614)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.widget.ListView.drawChild(ListView.java:3231)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.widget.AbsListView.dispatchDraw(AbsListView.java:2281)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.widget.ListView.dispatchDraw(ListView.java:3226)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.draw(View.java:11282)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.widget.AbsListView.draw(AbsListView.java:3769)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10616)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2504)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.draw(View.java:11180)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10616)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.draw(View.java:11180)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10616)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10614)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10614)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.draw(View.java:11180)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10616)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10614)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.draw(View.java:11180)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10616)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10614)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10614)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1373)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.draw(View.java:11180)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10616)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10614)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10614)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.View.getDisplayList(View.java:10614)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
    04-13 11:26:07.430 E/AndroidRuntime(10973): at android.view.ViewGroup.dispatchDraw(ViewGro
    04-13 11:26:07.650 D/Mono (10973): [0x2216328] hill climbing, change max number of threads 2
    04-13 11:26:10.660 D/Mono (10973): [0x2216328] hill climbing, change max number of threads 3
    04-13 11:26:11.200 D/Mono (10973): [0x2216328] hill climbing, change max number of threads 2
    04-13 11:26:12.120 D/Mono (10973): [0x2216328] hill climbing, change max number of threads 3
    04-13 11:26:12.200 D/Mono (10973): [0x322a310] hill climbing, change max number of threads 2
    04-13 11:26:14.980 D/Mono (10973): [0x322a310] hill climbing, change max number of threads 3
    04-13 11:26:15.310 D/Mono (10973): [0x322a310] hill climbing, change max number of threads 2
    04-13 11:26:18.810 D/Mono (10973): [0x322a310] hill climbing, change max number of threads 3
    04-13 11:26:18.860 D/Mono (10973): [0x322a310] hill climbing, change max number of threads 4
    04-13 11:26:18.920 D/Mono (10973): [0x322a310] hill climbing, change max number of threads 2
    04-13 11:26:20.420 D/Mono (10973): [0x2216328] hill climbing, change max number of threads 3
    04-13 11:26:20.450 D/Mono (10973): [0x2202528] hill climbing, change max number of threads 5
    04-13 11:26:20.560 D/Mono (10973): [0x2216328] hill climbing, change max number of threads 2
    04-13 11:26:23.340 D/Mono (10973): [0x2216328] hill climbing, change max number of threads 3
    04-13 11:26:23.480 D/Mono (10973): [0x2202528] hill climbing, change max number of threads 5
    04-13 11:26:23.610 D/Mono (10973): [0x2202528] hill climbing, change max number of threads 2
    04-13 11:26:25.530 D/Mono (10973): [0x2202528] hill climbing, change max number of threads 3
    04-13 11:26:25.700 D/Mono (10973): [0x2202528] hill climbing, change max number of threads 6
    04-13 11:26:25.840 D/Mono (10973): [0x322a310] hill climbing, change max number of threads 2
    04-13 11:26:26.080 I/Process (10973): Sending signal. PID: 10973 SIG: 9

  • batmacibatmaci DEMember ✭✭✭✭✭
    This looks like same problem. Updating 2.3.4 causes java stackoverflow exception as well. This didbt occur in 2.3.3. What is the Breaking change here?
  • darrell.tunnelldarrell.tunnell USMember ✭✭
    edited February 2018

    Have seen issue reported here: https://bugzilla.xamarin.com/show_bug.cgi?id=57728
    Problem still seems to be occuring as of latest stable release 2.5.0.122203
    Would be good to have an update on this..

  • batmacibatmaci DEMember ✭✭✭✭✭

    @darrell.tunnell said:
    Have seen issue reported here: https://bugzilla.xamarin.com/show_bug.cgi?id=57728
    Problem still seems to be occuring as of latest stable release 2.5.0.122203
    Would be good to have an update on this..

    is that only occurs for Samsun devices or Android 4 devices? my problem was with android versions smaller than 4.4 and it was caused by Syncfusion SfListview. I was told that they dont support under 4.4 so, I had to change the minimum version from api 15 to api 19. Is it also the problem for xamarin listview now?

  • darrell.tunnelldarrell.tunnell USMember ✭✭
    edited February 2018

    It appears to be a problem with ScrollView / ListView perhaps combination of the two, but only occurring on Android 4.4 and below (atleast for me)

  • EhsanJahanagiriEhsanJahanagiri USMember ✭✭

    Special thanks @darrell.tunnell

  • Esaavedra89Esaavedra89 USMember ✭✭

    @RenaudLaloire said:
    As a temporary fix, I just reduced the number of XAML elements in my ItemTemplate (I had more than 25), it just worked. If I re-add elements (even simple

    It seems that the ItemTemplate does not accept too many elements and if so, a StackOverflowError is raised.

    It seems to work. I reduced the numbers of elements inside of Listview and the nesting around the Listview.

Sign In or Register to comment.