StackOverflow when loading form with large calculations

What is the problem? Please be detailed.
java.lang.RuntimeException: An error occurred while executing doInBackground()
Caused by: java.lang.StackOverflowError: stack size 1037KB

What ODK tool and version are you using? And on what device and operating system version?
It is happen on my Lenovo Tab3 device, while Samsung device doesn't have any problem like this.
It might be the memory limit. And My ODK Collect Version is v1.10.0

What steps can we take to reproduce the problem?

What you have you tried to fix the problem?

Anything else we should know or have? If you have a test form or screenshots or logs, attach here.

This does seem to be a memory issue. Can your form be shared publicly? If so, it'd be really helpful if you could post it here. @dcbriccetti and @michal_dudzinski have been working on performance improvements and having access to more big forms that run into these kinds of problems would help target the improvements.

If you can't share your form publicly, maybe you could share some details about it. Does it have a select_one with lots of options, for example? How many questions does it have? Any media? Multiple languages?

1 Like

Thanks for your reply @LN .
Here is my form.
School Checklist.xml (1.1 MB)
School_Checklist_V10.xlsx (215.4 KB)

I hope you can give me some solution.

Hi, @LN,
You can see my log cat error here.

Hi. That stack trace and the form are very helpful. Thanks. I’ll see if I can reproduce the problem, which seems to be in JavaRosa.

@LN, or anyone, is it possible to increase the stack size in the field?

Thanks for sharing the form, @Bunhann_Thou!

@dcbriccetti Sorry, I don't understand your question!

For a standalone Java application, we can set the heap and stack sizes on the command line when we run. I’m wondering if someone who has installed an Android app can change the stack size.

Ah, interesting. I figured the limitation was a physical one since one device overflows and not the other but that's probably not the case. I don't know of a way to adjust the stack size and quick searching doesn't turn anything up.

@Bunhann_Thou what Android version does your Tab3 run?

I believe you can increase the stack size of a thread, but not on the main UI. https://stackoverflow.com/a/19967816/152938

Hi, @LN.
My device is running on Android 6.0 and It is Lenovo Tab 3-850M.
I already tested with Android 5.0 and Android 6.0 on Samsung devices and it doesn't show this error.
The specification of my Tab 3 are: RAM: 2GB, SoC: MediaTek MT6735.

Sorry for my bad English.

1 Like

@Grzesiek2010 When you have a moment, can you take a quick look in the Collect logs to see if this is a common error or reproducible?

I was able to reproduce the issue using my oldest device Samsung Galaxy Young GT-S6310 Android 4.1.2. Everything works well on my Galaxy S4 with Android 5.

When it comes to logs I was able to find some crashes caused by StackOverflow but logs look different. I'll add them to the issue create by @LN

2 Likes

Dear core team, I also recently deployed a form with seemingly few questions but quite elaborate calculations were used to populate fields because of the nature of the deployment and validate reported stack overflow. I deployed it without validate and it has successfully served the purpose -

But collect performance was not good on random 'weak' devices, so that some field teams struggled in the process.

SAVTool.xml (2.4 MB)
in case it might also be helpful as you continue the performance improvements for validate and collect.

Much appreciate.

Thanks for sharing this form. Do you have an XLSForm version you can share? It will help us more quickly understand the form.

@yanokwa , here is the xls form
SAVTool.xlsx (381.5 KB)

1 Like