Page 1 of 1

[Oxyd] [1.1.56] Some units/unitgroups are calling on_ai_command_completed events non-stop.

Posted: Wed Mar 16, 2022 1:47 am
by heyqule
What did you do?
I was doing performance profiling on my mod.

What happened?
I noticed unusual timing in show-time-usage on mods. When I tried to debug it, it seems the cause is the on_ai_command_completed event. Some units / unit groups are calling it non-stop. Since I'm not able to pull units by unit_number. I don't know which unit / unit group caused it and the reason for this issue.

What did you expect to happen instead?
When my mod is idle, show-time-usage reports erm-enemyracemanager 0.002/0.00x/0.0xx.

In the attached save, show-time-usage constantly reports 0.100/0.08x/0.6xx.

Extra Info
https://mods.factorio.com/mod/Unit_Control and my mod use on_ai_command_completed event in this save. I initially thought some player controllable units have bugged. But that's not the cause after I delete all player controllable units. The show-time-usage stayed the same for both mod. This issue affects mod that uses on_ai_command_completed event.

Modded Save:
https://drive.google.com/file/d/1qw-q4w ... sp=sharing

Here are the affected unit numbers that I pulled with log(event.unit_number) in on_ai_command_completed event:
https://drive.google.com/file/d/1D5Iu0- ... sp=sharing

I'm not sure whether the following is related to this unit issue. The unit group may sometimes freeze. They do not respond to attack or to have player military entities within their attack range. But their states are "AttackingGroupTarget" and "AttackingDistraction" in the debug tooltip.
https://drive.google.com/file/d/14Y80mg ... sp=sharing

P.S. It initially discovered in 1.1.53 stable.

Re: [Oxyd] [1.1.56] Some units/unitgroups are calling on_ai_command_completed events non-stop.

Posted: Mon Mar 21, 2022 2:15 pm
by Oxyd
It happens when you set a command (other than attack) as a distraction and it fails, it then fails on_ai_command_completed repeatedly instead of just cancelling the distraction. Nice find, fixed for 1.1.57.

Re: [Oxyd] [1.1.56] Some units/unitgroups are calling on_ai_command_completed events non-stop.

Posted: Mon Mar 21, 2022 7:37 pm
by heyqule
Thank you! Oxyd :D