Random crash regarding physics

Hi all,

I’m having a crash issue regarding physics. Here you can see the crash:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread  
0 org.Box2D.Box2D 0x001960f7 b2ContactManager::Collide() + 219  
1 org.Box2D.Box2D 0x001987aa b2World::Step(float, int, int) + 160  
2 com.anscamobile.Corona\_Simulator 0x00077ed9 0x1000 + 487129  
3 com.anscamobile.Corona\_Simulator 0x00078052 0x1000 + 487506  
4 com.anscamobile.Corona\_Simulator 0x000280b9 0x1000 + 159929  
5 com.apple.Foundation 0x9af70d03 \_\_NSFireTimer + 166  
6 com.apple.CoreFoundation 0x9c580996 \_\_CFRUNLOOP\_IS\_CALLING\_OUT\_TO\_A\_TIMER\_CALLBACK\_FUNCTION\_\_ + 22  
7 com.apple.CoreFoundation 0x9c580327 \_\_CFRunLoopDoTimer + 743  
8 com.apple.CoreFoundation 0x9c55f3e0 \_\_CFRunLoopRun + 1888  
9 com.apple.CoreFoundation 0x9c55e8ec CFRunLoopRunSpecific + 332  
10 com.apple.CoreFoundation 0x9c55e798 CFRunLoopRunInMode + 120  
11 com.apple.HIToolbox 0x9a7bda7f RunCurrentEventLoopInMode + 318  
12 com.apple.HIToolbox 0x9a7c4d9b ReceiveNextEventCommon + 381  
13 com.apple.HIToolbox 0x9a7c4c0a BlockUntilNextEventMatchingListInMode + 88  
14 com.apple.AppKit 0x93eab040 \_DPSNextEvent + 678  
15 com.apple.AppKit 0x93eaa8ab -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 113  
16 com.apple.AppKit 0x93ea6c22 -[NSApplication run] + 911  
17 com.apple.AppKit 0x9413b18a NSApplicationMain + 1054  
18 com.anscamobile.Corona\_Simulator 0x000023c5 0x1000 + 5061  

This crash is shown randomly. I guess this issue is related physics because I can see b2ContactManager::Collide() + 219 on the top of stack trace. I’ve tried to look for box2d code on Internet, but apparently CoronaSDK embeds Box2D differently, the line codes don’t match each other.

So, I have no idea why my game is crashing randomly. Has any developer had this problem too? Any ideas?

Thanks. [import]uid: 81082 topic_id: 18281 reply_id: 318281[/import]

do you remove bodies in a collision situation? [import]uid: 70114 topic_id: 18281 reply_id: 70045[/import]

As Sven said, do you remove bodies OR change them in anyway during collision? (This seems to be the most common cause of crashes where physics is concerned.)

Peach :slight_smile: [import]uid: 52491 topic_id: 18281 reply_id: 70109[/import]

Nope. I’ve commented out all collisions event listeners to make sure that’s not the problem.

But I got some new info, I’m using Director to change scenes, in this case I’m changing to the same scene which there are some physics objects, so if I “reload” the scene N times, randomly I got that error I described in my first post. Apparently I’m getting an error because there are overlapped physics layers or something like that. Director doesn’t unload the scene when it’s changed to the same scene.

There’s a solution to fix this: I can remove all physics layer before calling Director for changing the scene:

for i=levelGroup.numChildren, 1, -1 do  
 levelGroup[i]:removeSelf()  
end  

But in my case I cannot do that because I need the level on its state before reloading the scene, there’s a FX effect changing the scene. I think there’s no way to remove only the physics objects, I have to remove the whole object instead.

I’m still working on it, if you have any more ideas… it would be great!

Thanks for your replies. [import]uid: 81082 topic_id: 18281 reply_id: 70200[/import]

For any issues occurring because of Director we can’t provide a whole lot of support - you’d be best off trying the Director sub forum.

That said, if you plan on becoming a licensed user any time soon you should look into storyboard - it’s like Director but is from Ansca, so we can provide support there.

Peach :slight_smile: [import]uid: 52491 topic_id: 18281 reply_id: 70266[/import]