HUGE ComponentSystemGroup Disappointment. It Silently destroy PlayerLoop. Why?

We encounter a bug that some times our servers just stop running part of logic and every thing go wrong after that.

After few weeks of findings (because it was rare case) inside ComponentSystemGroup we find this:
5148089--509768--upload_2019-11-7_8-8-32.png

What the hell is that?
Why system just silently destroy PlayerLoop on single exception?
What the point in such behavior?
Why we even not notified about that?

May be there is some option to handle this undesired thing and return system back?

3 Likes

The exception is logged before it is destroyed. It’s not exactly silent.

Reason for that, I guess, it’s cause multithreading involved (jobs) and dependency chain, if one of systems throwing exception it can break whole chain, which in turn can miss disposing parts, it will cause huge memory leaks (especially in the editor), it can lead to race conditions (if chain broken, containers not diposed properly, some jobs not completed) and crash editor\build.

1 Like

You right we have exception but Exceptions is not an issue it just can be can not log some thing exception, but I can not know that inability to log something actually crash player loop :slight_smile:

Exception log is goo but it dont say anything bout destroy playerLoop :slight_smile: Thus I call it silent :slight_smile:

But destroying player loop lead to crash 100% of times. Just because systems depend on each other and if X system create entity but ECS deside to delete system that destroy these entities you have memory leak and so on.

Is not this lead to same results?
In my experience Exception far less destructive than system destory :frowning:
Exception always seen, but system that stop work and all errors that it caused all over other systems say nothing about destoryed part of game logic.

Bugs produced by absenae of destroyed systems looks like bugs from corrupted memory.

Nevertheless do any one know what Unity about to do with silent auto destroy of systems?
At least: LogError(“System {X} was removed from player loop because it throw unhandled exception” );

I had the same issue where my pathing system would sometimes fail once in a ~10000 path requests and would then stop working like your system did. Now I know why! I agree with you, the error should have said something about the removal process.

Anyway you can easily fix this by just dumping your OnUpdate code in your own try catch block and decide what to do with the exception yourself. In my case I decided to simply put a debug warning and skip the execution of that frame for that system. No more system removal and everything works normally.

Yeah :slight_smile: There I was lucky because we some time ago inherit dots system and redirect Update to Another method, in Update we gather stats. So all our systems now safe but…

What about 3rd party systems in near future from store, what about builtin systems?
If for example one of DOTS transform systems have very rare bug and raise exception, then somewhere deep in game players will start blame me because entire movement in game just stoped(or start to be crazy)!

What we can do then?

Where you’ll have leak? It’s not destroying any entities, it only removes system from chain to prevent future and repeated errors and the appearance of new entities, new job from the wrong code.

Note that the auto remove on exception behaviour has been removed, because it is madness…

In next entities release

9 Likes