Disposed Microbe Problem

I’m getting some clues about Disposed Microbe in Colony · Issue #2582 · Revolutionary-Games/Thrive · GitHub and Resolve the underlying issue with disposed microbes in engulf check · Issue #3174 · Revolutionary-Games/Thrive · GitHub after some testing. I’ll write here.

Here’s a typical log of microbes (Or colonies) that has a lot of disposed errors in it.

As you can see, for example, on Line 271, [RigidBody:28973] is disposed (died) at time 65051 ms. But later on, this microbe is engulfed 321 times from Line 275 (65159 ms) to Line 1508 (84313 ms)

My current opinion is that, when a microbe (i.e. player cell, A) begins contact with [RigidBody:28973], it is added to A.touchedMicrobes. Then, before the contact ends, [RigidBody:28973] died and is disposed. Without OnContactEnd called, that disposed microbe remains in the A.touchedMicrobes hashset. Every time A tries to begin engulf, it tries to engulf the disposed [RigidBody:28973]

Edit: Binding has the same problem. Trace [RigidBody:27798]

1 Like

Debugging screen record & log

Take notice of Microbe 11365 & 11466

Possible cause:

Possible solution (very rough one)

        // Disable collisions
        CollisionLayer = 0;
        CollisionMask = 0;

        // Stop all collisions
        foreach (var microbe in touchedMicrobes)
            microbe?.OnContactEnd(0, this, 0, 0);

EDIT: Not a solution…

I really like the floating label for the entities in the video, that’ll surely come in handy for debugging. Perhaps we can officially add them to the advanced F3 debug display, what do you think @hhyyrylainen?

I think it might be nice. As long as it doesn’t sap too much performance. It could be even an extra mode something like CTRL+F3 to toggle physics debugging (if that can be turned on during runtime) and entity labels.

If you like it, my debugging branch is GitHub - 84634E1A607A/Thrive at debug_disposed_microbe (really rough code)

1 Like

Makes sense to make it a separate CTRL+F3 mode, the performance metrics could be affected by a possible performance overhead of visible collision shapes plus the entity labels so grouping them together in the metrics display may not be the best. Also for toggling physics debugging in runtime, it might be possible: SceneTree.debug_collisions_hint.

Opened an issue:

Then I suppose we should add a debug menu instead of adding one shortcut and another.

Well let’s reserve CTRL+F3 for opening that? All of the most often used debugging helps, like the FPS counter, should still have their own buttons. Also I’m starting to get used to looking at the metrics view rather than just the FPS counter for seeing how well my changes perform.

Disposed microbes are all dead.

Somehow I’ve found that touchedMicrobes is not symmetric (I mean that A has B, but sometimes B doesn’t have A). My temprory fix is to check for dead microbes every time CanEngulf is called. But this is apparently not a good one.

That’s interesting. Probably caused by the physics system not triggering the callbacks symmetrically?
I think it’ll be fine to check if a microbe is dead before starting to engulf it, that kind of check makes sense to me.

This only applies to those newly spawned. The entities already on the scene won’t be affected.