I'm trying to use some JS script which has math.js included into it and some custom functions. Whole script takes around 1.5mb and it takes about 15 seconds to evaluate it using evaluateReader method of Rhino - though it's not possible to run it on UI thread. So we wrapped it into AsyncTask. Unfortunatelly running it from other thread then UI is making app to crash:
Caused by: org.mozilla.javascript.EvaluatorException: Too deep recursion while parsing (JavaScript#1133)
Line 1133 of our script is a part of math.js in Signature.prototype.expand:
for (i = 0; i < param.types.length; i++) {
recurse(signature, path.concat(new Param(param.types[i])));
}
I suppose that it can be somehow related to memory issues, as adding largeHeap to manifest helps, but only on some newer devices which allow it.
Is there any other solution that we can use that script and load it without blocking UI?
--- update 30.06
I've investigated memory management and it looks like this is some issue with memory. Rhino need additionall 25-30mb to get that script evaluated...