Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Too Deep Recursion

I am trying to get debugging working for the first time in Ti Studio using the 1.7.1 release and Android. When I launch my app (which works fine when run without debugging), it force closes on this error:

D/TiDebugSession( 1120): (Thread-11) [9,2100] rcvd request: 71*1308851347022*breakpoint*create*app:/views/vehicle/details.js*37*0*0**1
D/TiFastDev( 1120): (Thread-11) [26,2126] sent tokens successfully
I/dalvikvm( 1120): threadid=10: stack overflow on call to Ljava/lang/Character;.isJavaIdentifierStart:ZI
I/dalvikvm( 1120):   method requires 36+20+4=60 bytes, fp is 0x430cc338 (56 left)
I/dalvikvm( 1120):   expanding stack end (0x430cc300 to 0x430cc000)
I/dalvikvm( 1120): Shrank stack (to 0x430cc300, curFrame is 0x430cc824)
D/dalvikvm( 1120): GC_FOR_MALLOC freed 6130 objects / 467520 bytes in 108ms
W/dalvikvm( 1120): threadid=10: thread exiting with uncaught exception (group=0x4001d800)
E/TiUncaughtHandler( 1120): (Thread-11) [635,2761] Sending event: exception on thread: Thread-11 msg:org.mozilla.javascript.EvaluatorException: Too deep recursion while parsing (file:///android_asset/Resources/views/vehicle/details.js#289); Titanium 1.7.1,2011/06/21 14:28,293a6d
E/TiUncaughtHandler( 1120): org.mozilla.javascript.EvaluatorException: Too deep recursion while parsing (file:///android_asset/Resources/views/vehicle/details.js#289)
E/TiUncaughtHandler( 1120):     at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109)
E/TiUncaughtHandler( 1120):     at org.mozilla.javascript.Context.reportRuntimeError(Context.java:945)
E/TiUncaughtHandler( 1120):     at org.mozilla.javascript.Parser.parse(Parser.java:587)
E/TiUncaughtHandler( 1120):     at org.mozilla.javascript.Parser.parse(Parser.java:506)
E/TiUncaughtHandler( 1120):     at org.mozilla.javascript.Context.compileImpl(Context.java:2401)
E/TiUncaughtHandler( 1120):     at org.mozilla.javascript.Context.compileString(Context.java:1367)
E/TiUncaughtHandler( 1120):     at org.mozilla.javascript.Context.compileString(Context.java:1356)
E/TiUncaughtHandler( 1120):     at org.mozilla.javascript.tools.debugger.Dim$DimIProxy.run(Dim.java:1027)
E/TiUncaughtHandler( 1120):     at org.mozilla.javascript.Context.call(Context.java:521)
E/TiUncaughtHandler( 1120):     at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:535)
E/TiUncaughtHandler( 1120):     at org.mozilla.javascript.tools.debugger.Dim$DimIProxy.withContext(Dim.java:1078)
E/TiUncaughtHandler( 1120):     at org.mozilla.javascript.tools.debugger.Dim$DimIProxy.access$3(Dim.java:1077)
E/TiUncaughtHandler( 1120):     at org.mozilla.javascript.tools.debugger.Dim.compileScript(Dim.java:667)
E/TiUncaughtHandler( 1120):     at ti.modules.titanium.debug.DebugServer.c(Unknown Source)
E/TiUncaughtHandler( 1120):     at ti.modules.titanium.debug.DebugServer.b(Unknown Source)
E/TiUncaughtHandler( 1120):     at ti.modules.titanium.debug.handlers.a.a(Unknown Source)
E/TiUncaughtHandler( 1120):     at ti.modules.titanium.debug.h.b(Unknown Source)
E/TiUncaughtHandler( 1120):     at ti.modules.titanium.debug.h.run(Unknown Source)

I added this to my tiapp.xml but it had no effect:

<property name="ti.android.threadstacksize" type="int">327680</property>

Was anyone else able to get debugging working? What am I missing?

— asked June 23rd 2011 by Justin Toth
  • android
  • debugging
  • recursion
  • stackoverflow
0 Comments

7 Answers

  • Now that you've added the stack size property, run a clean on your project then rebuild.

    — answered June 23rd 2011 by Anthony Decena
    permalink
    3 Comments
    • @Anthony - I don't see any clean option within Ti Studio, however I did try clearing out the build/android folder if that's what you mean. It has no effect, I still get the recursion error.

      — commented June 23rd 2011 by Justin Toth
    • The clean option is under the "Project" main menu. Running it does the same as clearing that android build folder, however, just to cover all bases, try using that option and building again.

      — commented June 23rd 2011 by Anthony Decena
    • @Anthony - Same issue after clean…

      — commented June 23rd 2011 by Justin Toth
  • @Anthony - Same issue after clean…

    — answered June 23rd 2011 by Justin Toth
    permalink
    0 Comments
  • Seems 'ti.android.threadstacksize' should be 32768 rather than 327680 !?

    — answered June 23rd 2011 by Pascal Burel
    permalink
    1 Comment
    • I tried both and they give the same error.

      — commented June 23rd 2011 by Justin Toth
  • could you post details.js ? for some advice …

    — answered June 23rd 2011 by Pascal Burel
    permalink
    0 Comments
  • Here is details.js, however there are a bunch of shared controls so this isn't all of the code. Keep in mind that running it normally on the simulator or on the device works fine, only debugging gives the recursion error so it makes me think it doesn't have to do with my code at all.

    http://pastebin.com/muzqYC25

    — answered June 23rd 2011 by Justin Toth
    permalink
    0 Comments
  • Justin

    Please take note of this advice in the docs: Avoid deep nesting

    Setting threadstacksize to very large values is likely to cause problems; 128K or lower is recommended.

    Hope this helps

    — answered June 23rd 2011 by Paul Dowsett
    permalink
    4 Comments
    • Hey, I tried the recommended value of 32768 and it still gives the same recursion error when trying to debug.

      — commented June 23rd 2011 by Justin Toth
    • Justin, indeed, it is important to ensure that threadstacksize does not exceed the recommended value. However, to avoid deep recursion issues specifically, you should follow the advice in the link I provided.

      Thanks

      — commented June 24th 2011 by Paul Dowsett
    • I don't have "several levels of nested loops or recursive code", I don't even use recursion in this app. If it was an issue in my code then it would happen when not debugging too. The fact that it only happens when trying to debug implies an issue with the debugging feature.

      — commented June 24th 2011 by Justin Toth
    • I should also mention that I've seen other posts in this forum about seeing this issue when they were using 2-3 levels of subdirectories in their app, which is the case for me as well.

      — commented June 24th 2011 by Justin Toth
  • Are you using the MYAPP.os funciton/macro from the Tweetanium app? I had been using it in my mediaplayer file, but began getting too deep recursion errors on android. Once I shopped out to a playerview_ios.js and a playerview_android.js, I was fine. Check the file you're getting the error from and consider splitting the android and ios logic up into separate files. At Ti.include time, conditionally include ONLY the proper file.

    — answered June 24th 2011 by Anthony Sosso
    permalink
    1 Comment
    • I'm not using that. The file that it says has the recursion issue does have 9 include statements in it, however all 9 are needed in both Android andiOs so there's nothing I can do to slim that down.

      — commented June 24th 2011 by Justin Toth
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.