physics.stop() randomly crashes; physics.pause() displaces my dynamic objects

Hi,

i am just developing a game with static and dynamic physics objects. I also use storyboard for scene transitions.  

Now i implemented a reload button which simply reloads the Scene with storyboard.reloadScene(). In short the structure of my storyboard Scenes are as follows:

scene:createScene( event )

– i do nothing :slight_smile:

scene:willEnterScene( event )

– physics.start()

– load Level (graphics incl. physics bodies)

scene:enterScene( event )

– add Event listeners

scene:exitScene( event )

– remove Event listeners

– remove graphics and physics objects.

– physics.stop() or physics.pause()

Everything would work great if physics.stop() would not crash the Simulator and also the app. It crashes randomly. sometimes after 3 refreshes sometimes after 30 refreshes.

So i replaced physics.stop with physics.pause(). Now the app and the Simulator does not Crash anymore. But the issue now is that my dynamic physics objects are a little bit displaced and the game is unplayable. Please see the attached pic. I have no idea anymore what i can do. Is there any fix in the Pipeline concerning the physics.stop() bug?

Thanks in advance for any ideas or help.

Thomas

Edit: i just found out that when i move my level creation code from the willEnterScene to the enterScene the displacement is gone. why?  

I just found out that the random crashes happen, when Pivot Joints are NOT removed before physics.stop() is executed. It would be great if this could be fixed in the near future. Thanks in advance.

If that is the case you should make a simple test project and submit it to Corona via the report a bug link, at the top of the screen.

They need that doing in order to verify it and assign it to be fixed etc.

I just found out that the random crashes happen, when Pivot Joints are NOT removed before physics.stop() is executed. It would be great if this could be fixed in the near future. Thanks in advance.

If that is the case you should make a simple test project and submit it to Corona via the report a bug link, at the top of the screen.

They need that doing in order to verify it and assign it to be fixed etc.

I just came across this bug also - seems to still be present in the latest build (2239). I can’t believe more people haven’t noticed it!

Hello @landoncope,

When and where you pause/stop the physics engine (which event in the Composer framework) is essential. Also, using physics.stop() needs to be treated carefully, since this call “destroys” the entire physics world, and may result in crashing if there are some lingering activities or calls that reference the physics engine. Personally, I never use .stop(), but only .pause(), since there’s typically not a reason to destroy the entire physical world.

Best regards,

Brent

I met the problem too. My application crashes randomly when I change “physics.pause” to “physics.stop”.

why I change to “physics.stop”?

Because when I reload physic level with levelhelper api, the level seems cannot be reset cleanly, when change to “physics.stop”, it’s ok.

Here’s an old thread that might be of help:

http://forums.coronalabs.com/topic/19134-solved-odd-physics-crash-that-isnt-collioson-based/?hl=%2Bphysics+%2Bstop+%2Bcrash

I ended up just not using physics.stop - it is definitely buggy on the ipad (which bugs are not manifest in corona or xcode simulators). Physics.stop is convenient as it ensures that everything is cleared from the physics world and can be a big timer saver. However, you’ll probably end up having to carefully track all of your physics objects and remove/destroy them at the appropriate times, particularly joints.

I just came across this bug also - seems to still be present in the latest build (2239). I can’t believe more people haven’t noticed it!

Hello @landoncope,

When and where you pause/stop the physics engine (which event in the Composer framework) is essential. Also, using physics.stop() needs to be treated carefully, since this call “destroys” the entire physics world, and may result in crashing if there are some lingering activities or calls that reference the physics engine. Personally, I never use .stop(), but only .pause(), since there’s typically not a reason to destroy the entire physical world.

Best regards,

Brent

I met the problem too. My application crashes randomly when I change “physics.pause” to “physics.stop”.

why I change to “physics.stop”?

Because when I reload physic level with levelhelper api, the level seems cannot be reset cleanly, when change to “physics.stop”, it’s ok.

Here’s an old thread that might be of help:

http://forums.coronalabs.com/topic/19134-solved-odd-physics-crash-that-isnt-collioson-based/?hl=%2Bphysics+%2Bstop+%2Bcrash

I ended up just not using physics.stop - it is definitely buggy on the ipad (which bugs are not manifest in corona or xcode simulators). Physics.stop is convenient as it ensures that everything is cleared from the physics world and can be a big timer saver. However, you’ll probably end up having to carefully track all of your physics objects and remove/destroy them at the appropriate times, particularly joints.