Crash Unity

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: Crash Unity

Postby pysnoo » Wed Oct 24, 2018 2:38 am

Open the scene "Entry", press Play to launch Unity.
When it's launched, press Space, it will open automatically a new scene with a lot of bodies falling from the sky.
Then press Play to stop Unity, it will crash sometimes. If not, retry the same procedure again.
pysnoo
 
Posts: 24
Joined: Mon Oct 08, 2018 9:08 am

Re: Crash Unity

Postby Julio Jerez » Wed Oct 24, 2018 11:14 am

Oh I see< open the scene a launch it, I get all thsi errors, is that right?
Untitled.png
Untitled.png (155.86 KiB) Viewed 7268 times
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash Unity

Postby pysnoo » Wed Oct 24, 2018 11:22 am

Not really, when I open this scene and press play I got no errors.
pysnoo
 
Posts: 24
Joined: Mon Oct 08, 2018 9:08 am

Re: Crash Unity

Postby Sweenie » Wed Oct 24, 2018 11:34 am

Maybe it would be easier if i try to create a test scene in the plugin project that reproduce the problem.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Crash Unity

Postby Julio Jerez » Wed Oct 24, 2018 11:36 am

that's the download, not changes.
when I run it nothing happen when I press space.
are you sure I have the right download?

those errors say there are objects with null pointers,
I will see what is that about.

tell me is the scene all generated procedurally, I see not object s anywhere.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash Unity

Postby Julio Jerez » Wed Oct 24, 2018 11:43 am

Sweenie if you can do that, it will help a lot.
this seem to be some bug that happen for long time and we never catches it. but every person who has try the plug it has found it, or found a similar crash.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash Unity

Postby pysnoo » Thu Oct 25, 2018 3:15 am

I just downloaded the project in my last download link (do you take the last one ? not the one on my first post) and I have no errors.
But I had to make multiple times reloading/unloading scene to got the crash (maybe it's related with memory consumption).

Sweenie it would be cool if you can reproduce it in the plugin project (I don't know where it is).
Let me know if you need help.
pysnoo
 
Posts: 24
Joined: Mon Oct 08, 2018 9:08 am

Re: Crash Unity

Postby Sweenie » Thu Oct 25, 2018 5:46 am

I found some serious bugs on how we handle creating bodies at runtime.

When the scene starts the world will find all rigid bodies in the scene and call their method "InitRigidBody" which creates the native/nonmanaged body instance and colliders.

When creating a body from script you would therefor need to call InitRigidBody.
The reason we had that was to prevent the bodies(created in the editor) from initializing before the world was created which could happen since Unity doesn't init the gameobjects in fixed order(unless you fiddled with script execuption order)
But I realized now that the world is available immediately since we create it in the constructor and not in it's start method.
So i removed the body-init stuff from the world start method and instead let the bodies init themselves in their own start method.
The same for the joints.
Also had to make sure that if a joint was initialized before a body the joint would call InitRigidBody as well to make sure the body is created before the joint.

So calling InitRigidBody shouldn't be necessary anymore. But I made sure it is safe to call InitRigidBody any number of times now. It won't do anything if called more than once.

This leads us to the bug i found.
I made a scene called stresstest which creates 200 cubes with a box collider, waits a couple of seconds, destroys them and then create 200 new cubes.
When the script's "Start" method is called i first created 200 cubes.
Then they were destroyed and suddenly the NewtonWorld update method started flooding the log with null reference exceptions(like in Julios screenshot in this thread).

What happened was that I create 200 gameobjects with a body and collider and call InitRigidBody.
The bodies was created and also register themselves in the NewtonWorld body list(using the RegisterBody method on NewtonWorld).
Then the NewtonWorld start triggers and immediately starts to register these 200 bodies again.
This would create 200 new bodies and colliders(native only) and make another call to RegisterBody()
Now we have 400 registered bodies in the world list since each body is registered twice.

Then a couple of seconds later the 200 bodies are destroyed(the gameobjects) and they unregister themselves from the NewtonWorld by calling UnregisterBody().
Then in the next frame NewtonWorld loops through the body list which isn't empty but still contain 200 references and calls ApplyForceAndTorques but all the bodies in the list has been deleted thus throwing nullreference exceptions.

Now I'm not 100% sure if this is what caused the crash but it was definitely as serious bug.

I got the crash once before I found this bug and haven't managed to get a crash after fixing it but it could still be another bug causing the crash so please update and recompile the plugin and try your scene again.
You can also try the "stresstest" scene I created in the plugin project. It's in the Assets folder along with all demos scenes.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Crash Unity

Postby pysnoo » Thu Oct 25, 2018 8:02 am

I tried it in my crashtest project, I had no crash. It seems to work.
I will test in my real project.
Thank you
pysnoo
 
Posts: 24
Joined: Mon Oct 08, 2018 9:08 am

Re: Crash Unity

Postby Sweenie » Thu Oct 25, 2018 9:19 am

I noticed your test scene became much more responsive on my crappy work computer after the bug fix. This seems to indicate that your pallets were initialized twice which would have created one extra body and compound collider for each pallet, invisible though since the visual Unity model would only be connected to the body created the second time. The physics world would also have these "ghost" bodies lying around colliding with everything until the garbage collector disposed it.
Hmm, thinking about it, it may have been the garbage collecting of these "ghost" objects that caused the crash. Well, let's see if your real scene works after this.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Crash Unity

Postby Julio Jerez » Thu Oct 25, 2018 9:57 am

oh very cool, I like the idea of getting rid of the init body called by the world, and instead be the body itself who does it.
the common thing from the people who has similar crashes is that they do runtime creation and disposal of bodies and joints, that was never considered when we made the plug it, we simply assumed it was like objects made in the editor.

it does really sound this was the reason for those random crash which will be different form crash to crash, but still be the same reason.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash Unity

Postby Sweenie » Thu Oct 25, 2018 10:31 am

the common thing from the people who has similar crashes is that they do runtime creation and disposal of bodies and joints, that was never considered when we made the plug it, we simply assumed it was like objects made in the editor.


Yep, none of our demos create bodies at runtime but use editor-created bodies, except for demo 18 which spawns objects. I think i've seen that crash some times.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Crash Unity

Postby pysnoo » Fri Oct 26, 2018 4:06 am

Hi, I tried in my real project and it's still crashing :cry:

Can you describe me please how I have to handle my bodies (InitRigidbody function, did I have to handle destroying them or automatically ?).

I have an entry scene containing NewtonWorld and after I'm loading different scenes with newtonbodies inside them.

EntryScene will stay during all the simulation instead other scenes are loading/unloading

Thank you
pysnoo
 
Posts: 24
Joined: Mon Oct 08, 2018 9:08 am

Re: Crash Unity

Postby Sweenie » Fri Oct 26, 2018 8:48 am

yes, i tried your test scene again and managed to get a crash as well. But it doesn't happen often on my computer. I have to press space and r several hundred times before it happens.

I noticed your pallet object have some unnecessary colliders though.
The top object(the box with straps) have 17 boxcolliders on it. 1 for the box and 16 for the pallet.
Then you have the subobject(pallet) which also have 16 boxcolliders.
The 16 boxcolliders for the top object isn't needed.

Also I saw an object called "Trigger" which for some odd reason creates a static body with a boxcollider as well.

Regarding creating the pallet objects. The NdPrefabScript calls InitRigidBody at the end, that won't be necessary anymore but that can't be the reason because I fixed that in the latest update.

But i need to test this further and see if I can reproduce the crash in my stresstest scene again. For example if it's related to LoadSceneAsync or not or related to compound colliders.

What if you build your testproject as an executable? Does that crash as well?
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Crash Unity

Postby pysnoo » Fri Oct 26, 2018 10:11 am

Thank you for searching, and yes I built it as an executable and it crashed very often.
pysnoo
 
Posts: 24
Joined: Mon Oct 08, 2018 9:08 am

PreviousNext

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 7 guests

cron