Page 1 of 1

[0.17.68] Desync with mod caused by different serialization order

Posted: Wed Sep 18, 2019 4:32 pm
by Therenas
I'm the author of the mod Factory Planner, and I just got a desync report from a user. He took a look at the desync report and noticed that the difference was not with the actual data, but with the order that it was saved in. I'm no good at interpreting desync reports, but I don't know how a mod can affect the serialization order of lua tables. I'd like to think it shouldn't be able to, but I don't know, maybe I'm missing something.

The desync reports are linked in the discussion thread. I investigated my code and I'm pretty sure I don't do any of the typical desync-causing stuff, like modifying global during on_load, or using read/write lua-global variables.

Re: [0.17.68] Desync with mod caused by different serialization order

Posted: Thu Sep 19, 2019 2:43 am
by Rseding91
Thanks for the report. The script contents may be different and there may be a bug around that logic but the desync itself is never triggered due to the contents of the script file. The desync is always triggered by what's different in level-heuristic.dat.

Re: [0.17.68] Desync with mod caused by different serialization order

Posted: Thu Sep 19, 2019 9:15 am
by Klonan
The heuristic shows some diff in the number of active entities

Well, I am going to move this to desyncs with mods

Re: [0.17.68] Desync with mod caused by different serialization order

Posted: Thu Sep 19, 2019 10:09 am
by Deadlock989
I was paranoid that this was being caused by my mod, so I did some poking.

The only diff in the heuristics (which I barely understand) is on line 626, it mentions trains and active entities. My mod doesn't create or destroy any entities via scripting.

The report came from folks who were running a pack that includes the mod Electric Train. Looking at that mod's control.lua, it seems that it does use two local variables (i.e. defined outside of all functions, not in the global table) that are used by several functions, and it does create and destroy trains based on the values of those variables. Presumably any player that left and then returned would end up with different values.

I don't know that much about desyncs in Factorio but this seems like a good place to start.

Re: [0.17.68] Desync with mod caused by different serialization order

Posted: Fri Sep 20, 2019 7:02 am
by Therenas
Well, that should put it to bed. Thanks again Deadlock. I just was kind of paranoid because I got two desync reports in two days, with both not being my fault after all. Sorry to bother.