"Too much recursion" SpiderMonkey error started after cocos2dx upgrade

348 views
Skip to first unread message

Mark Henderson

unread,
Apr 23, 2013, 10:18:28 PM4/23/13
to cocos2d-...@googlegroups.com
(reference http://www.cocos2d-x.org/boards/20/topics/27163)

We've just updated our code to use the latest cocos2dx stable release (the 2.1.2 hotfix) and various unrelated parts of our javascript code started throwing errors for "Too much recursion".

The code worked fine before the upgrade, and it's not recursive code.  We've only seen this error on Android. Commenting out a few lines where the errors happen tend to let the code past, only to error in another spot.

I know that there is a constant in the c++ files of Spidermonkey that allows the call stack depth to be controlled.  Is it possible that was set to a low value when the current android libraries were built?

If anyone has any suggestions for looking into this, I would definitely appreciate hearing them.

I've posted up some code examples on the forum post I mentioned.

Rolando Abarca

unread,
Apr 24, 2013, 12:52:48 PM4/24/13
to Mark Henderson, cocos2d-...@googlegroups.com
You might need to set the stack quota after creating the runtime. I remember fixing this some time ago, in ScriptingCore.cpp. But you can give it a try:

JS_SetNativeStackQuota(JSRuntime *cx, size_t stackSize);

A good size is 500000.

Just checked this, it was fixed in cocos2d-ios:

https://github.com/zynga/jsbindings/blob/master/src/manual/jsb_core.mm#L348

You might want to do the same in cocos2d-x jsbindings.


Rolando



--
You received this message because you are subscribed to the Google Groups "cocos2d JS development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocos2d-js-dev...@googlegroups.com.
To post to this group, send email to cocos2d-...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--

Mark Henderson

unread,
Apr 24, 2013, 2:31:55 PM4/24/13
to cocos2d-...@googlegroups.com, Mark Henderson, m...@rolando.cl
That was exactle the problem, and adding that single line fixed the crash we were having.

I noticed you added several other lines in the commit for that, including something around security and trusted principals.  Is that code that should be ported fully over to cocos2dx?

For now I've just taken the quota line to get past our errors.  our ScriptingCore::createGlobalContext function now looks like:


    this->rt_ = JS_NewRuntime(10 * 1024 * 1024, JS_NO_HELPER_THREADS);

    size_t stack = 500000;

    JS_SetNativeStackQuota(this->rt_, stack);

    this->cx_ = JS_NewContext(rt_, 10240);


Thanks a bunch!
Mark
Reply all
Reply to author
Forward
0 new messages