Chipmunk test of buoyancy in TestJavascript project will crash

chipmunk test of buoyancy in TestJavascript project will crash if you press the center button twice or more times.
cocos2d-x-2.2.3
crash snapshot

I met a similar problem in my own project, that the js gc always crash the game occasionally if i replay the game once or more times with new cp.Space recreate. I do use the exposed destroy method for cp.Space object, but there is no free operation exposed to the JS. I’m not sure this is a problem.
But I find it is so easy to reproduce the crash by TestJavascript’s chipmunk buoyancy test.
Does any one have a clue to fix the problem?


DC12AC60-5CB8-4338-A526-7C4DA91511FC.png (149.2 KB)

I use Object style of chipmunk, the C style do have a cp.spaceFree method.

Hi. @damai

This is a issue of JSB, I will check it out
Thanks

Hi, @pandamicro
Anything I can do to fix this problem in version 2.2.3 ?

@damai I haven’t found the reason to this issue yet, if you found something first, please let me know

@pandamicro
if I comment the space.addCollisionHandler in the last line, the crash wont happen.
And the crash is caused by the GC’s runtime, it is null in SprideMonkey’s JS_GC operation function.
Maybe the collision handler’s JSRuntimeContext be deleted some where.
Hope this is helpful for you.

Hi, @damai

I have fixed this issue in Cocos2d-JS v3.0 RC0, it’s due to code structure of the test case itself and collision handler wasn’t well managed.

You can compare the old code and the code in newest version.

Hi, @pandamicro and guys.
Unfortunately, I have the same bug in recreating my gameplay scene with cp.Space in v3.0 RC3.
Collision Handlers are working great before “restart” but produce EXC_BAD_ACCESS in XCode after I’ve recreate scene and space.
I agree with @damai: it’s looks like JSRuntimeContext is deleted after “restart”.