Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1805] Android: Too deep recursion

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionWon't Fix
Resolution Date2013-08-01T00:11:57.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0
ComponentsAndroid
Labelsandroid, defect, recursion, rhino, rplist, stackoverflowerror
ReporterMarshall Culpepper
AssigneeIngo Muschenetz
Created2011-04-15T03:02:52.000+0000
Updated2017-03-20T17:53:34.000+0000

Description

Some apps will cause Rhino / Dalvik to reach a StackOverflowError and show an error message "Too deep recursion when parsing". We need to either increase the stack size of the Thread that parses the Javascript, or pre-compile the AST so the parsing doesn't happen on device (the latter might be good for speed anyway)

Attachments

FileDateSize
module_media.zip2012-01-20T11:55:20.000+00004873819
module_media log.txt2012-01-20T11:55:20.000+000019193
sample_cloud_log.txt2012-04-26T15:19:15.000+000013383
sample_cloud.zip2012-04-26T15:19:15.000+00003197608

Comments

  1. Marshall Culpepper 2011-04-15

    (from [ef98bfab872f7a5b08398a809da37b5ffe67a550]) use a 16K stack for Javascript parsing, this seems to give more room so some apps don't spit out the "Too deep recursion" error. copied the android HandlerThread class in so we could expose the stack size constructor of Thread [#1805] http://github.com/appcelerator/titanium_mobile/commit/ef98bfab872f7a5b08398a809da37b5ffe67a550"> http://github.com/appcelerator/titanium_mobile/commit/ef98bfab872f7...

  2. Marshall Culpepper 2011-04-15

    (from [99989c74f5b83ad5fc6c45601d21e6ada78e16e1]) 16K, not 16M (good eye Bill) [#1805] http://github.com/appcelerator/titanium_mobile/commit/99989c74f5b83ad5fc6c45601d21e6ada78e16e1"> http://github.com/appcelerator/titanium_mobile/commit/99989c74f5b83...

  3. Jick Steen 2011-04-15

    FYI: I ran into this issue after I minified my JS using "google closure". I also merged all "library" files into one file before building a release version to reduce stat calls. The result was a file larger than 40k. Dont know whether the file size has something to do with the stack size.

  4. Marshall Culpepper 2011-04-15

    (from [54629899a5631d2d2e1ef9ca4025c5831f640d1a]) initial implementation of Rhino JS->bytecode compiler for production apps, dramatically decreasing startup time and runtime code execution in general. this falls back on dynamic/unoptimized evaluation when a compiled script isn't found, and each file is compiled separately to avoid the arg size limit in windows. added a "ti.android.threadstacksize" property that allows each app to control the stack size allocated for each JS thread (by default it's 16K, but this may not be big enough for some apps) [#1109] [#1805] http://github.com/appcelerator/titanium_mobile/commit/54629899a5631d2d2e1ef9ca4025c5831f640d1a"> http://github.com/appcelerator/titanium_mobile/commit/54629899a5631...

  5. Jick Steen 2011-04-15

    Hi Marshall,

    how can someone determine the best/correct/needed threadstacksize?

    Best regards

  6. Marshall Culpepper 2011-04-15

    @Jick

    Try the new default stack size, and if you're still seeing the "Too deep recursion" error, you might need to try specifying something larger (I'd recommend increasing by factors of 2)

  7. Marshall Culpepper 2011-04-15

    (from [d8ba51d99dd0a067968102ad63b628aad4d8fc71]) fixed a source code generation bug when a tiapp.xml property had an empty / bad value, turned on deploy type and a new ti.android.compilejs property to control when/if JS gets compiled for an application [#1805] http://github.com/appcelerator/titanium_mobile/commit/d8ba51d99dd0a067968102ad63b628aad4d8fc71"> http://github.com/appcelerator/titanium_mobile/commit/d8ba51d99dd0a...

  8. Matt Schmulen 2011-04-15

    regression tested on 1.5.0 (11/22/10 20:42 19a59fd) Android sim 2.1,

    function recurse(count) {

       return ( count > 0 ) ? recurse( count - 1) : count;
       

    };//end recurse

    recurse(1000000);

  9. Thomas Huelbert 2011-04-15

    resolved as per Matt

  10. Dustin Hyde 2012-01-20

    Reopening Issue. Bug Still Valid. Attached new fail-case test project: module_media.zip Attached runtime error log: module_media log.txt Error caused by: module_media/Resources/acceptance.js > tpl.at.timob_5900 = function (_window) {...}) (lines 248-332) There is a syntax/semantic error in this function involving two extra curly braces (lines 248 and 328). Removing them will allow the app to run. Note: Studio does not recognize the error and there are no recursion errors in iOS/V8 (these platforms appear to behave correctly). SDK: 1.9.0.v20120119134634, 1.8.0.1.v20120119133134 Android: Rhino Studio: 1.0.8.201201190907 OS: Lion Devices Tested: Galaxy Nexus 4.0.2, Droid3 2.3.4 Steps to Reproduce: 1. Run project using Rhino. Expected Result: App should run. Actual Result: Runtime Error.
  11. Wilson Luu 2012-04-26

    Also getting too deep recursion error when running the cloud sample app. Bug appears on: SDK build: 2.0.1.GA2 Runtime: Rhino Titanium Studio, build: 2.0.2.201204252015 Device: Droid 3 2.3.4 Steps to reproduce: 1. Launch cloud_app in rhino
  12. Chris Barber 2013-08-01

    Won't fix because Rhino is no longer supported.
  13. Lee Morris 2017-03-20

    Closing ticket as Rhino is no longer supported.

JSON Source