Loading saved game with mods causes mods and game to load at the same time

💥 Crash 🕹️ Performance 🚨 Severe / game breaking
This topic is closed (tagged ).
10 days ago

This started as a report that seemed to be outside intended circumstances, but i've dug deeper and have uncovered a critical problem in how the game loads, one that may have only cropped up for me but could very well become a problem as modpacks grow larger.
At the very least, i believe this is worth taking a look at
Edit: found a workaround that worked the 2 times i tested it, added to the workaround section

edit 2: did more tests, the issue is with a specific mod's version of harmony, but it only appears due to mods not being pre-loaded when loading a game through the continue or load menus. at least, that's my current theory. i'll keep running tests if asked so check further down in the thread to see what's been uncovered

Edit 4:

Hi devs that might be reading this! This bug report covers 2 different problems.

  1. A bug with a version of harmony used in v0.5.0 of the cargo helicopter mod
  2. Loading saved games doesn't pre-load extra content, like DLC and mods, meaning the processes to load mods and the process to load the game happens at the same time. In some cases, this can cause problems as the two processes don't expect the other to be running leading to problems. This is the root cause of #1.

Please address whichever you think applies to you, and feel free to ask me to clarify/test things.
hopefully this is the last edit i'll make.

edit 5: nvm i'm going to change the title, " Game Crash when loading due to harmony interupting "Delayed deserialization" " -> " Loading saved game with mods causes mods and game to load at the same time "
end of edits

TL,DR: If a mod uses 0Harmony.dll, the harmony patching process can interrupt the game loading process at the "Delayed deserialization" stage and prevent core game systems from loading, causing a crash

RECREATION

  1. Exist on linux, playing the game through steam proton
  2. Add pique's Cargo helecopter mod to the load list (https://coigame.com/Mod/1102/Cargo-Helicopter)
  3. watch as the game freaks out after loading terrain while trying to initialize UI
  4. wait for the memory leak to cause a crash, or some failsafe to crash the game

    I've attached a recording of the crash due to how strange it looks, it's the fail safe version as a crash window kicked in and shut down the game when the footage freezes

footage transcript (just in case):

  • Starting on main menu, going to load a save
  • open up the mod menu
  • struggle for a moment to find where the cargo helecopters mod is, it is pre-enabled due to previously getting it working
  • load the save
  • loading proceeds normally until about 50%
  • the background art goes a peach colour, the loading bar resets to about 25%, 2 parts of the HUD load in (the search bar and a spacer on the left), and the tips switch rapidly
  • footage freezes as the game crashes itself

PRESUMED CAUSE

(please note: this was written before i discovered the loading bug, as such this is a surface level explanation)

As mentioned, i believe this is due to a strange interaction between the cargo helicopter mod and either the game or steam proton, due exclusively to this file

image.png
0Harmony.dll
I believe this for 2 reasons

  1. as the video shows, I have several other mods in use, not one other has this file included and i've never encountered this error before
  2. the log files mention harmony patches, with the text reader i'm using displaying this in orange text, the only coloured text in the entire log file
    image.png

I DO NOT BELIEVE THIS IS A MALICIOUS FILE


I have seen 0Harmony.dll before when modding kerbal space program, and never had issues with it there. But this is the first time i've seen it when modding Captain of Industry, and it's the only thing i've noticed being different with this mod compared to everything else. Not only that, looking in the logs reveals that the game crashed due to a GUI error, with mentions of failing to initialize a UI component.
image.png

DIGGING DEEPER

I did manage to get the aforementioned mod loaded once before, and wrote basically the rest of this report before going and looking at the log files for that instance, and i've noticed something worth mentioning.
I think this has something to do with when harmony kicks in its patches during the loading process. As shown in the above screenshot, harmony appears midway through a different mod's initialization, in a "Delayed deserialization" period. This interupt doesn't happen in the logs of the loaded instance, as this "Delayed deserialization" period finished before harmony applied patchesimage.png
Comparing the two log files, it seems that a section of core game systems don't initialize in the crash version before harmony jumps in. The logs mention functions for "serealization", "maintenence", "game loader", "game builder", and "gameplay scene" that are completely missing from the crash version. It's possible that other functions were also cut off from initializing properly in this version, but none were critical to cause the game to crash.
My guess as to what is happening is that when the "delayed deserialization" period starts, harmony also starts up to add its patches. This doesn't happen instantly, either due to processing or a delay timer. if the "delayed deseralization" period takes too long however, harmony jumps in to interupt it. This prevents the period from properly finishing, leaving core game systems improperly set up. Which causes the game to tear itself apart upon trying to load the save.

WORKAROUNDS

This is a problem with how the game itself loads and interacts with harmony
If this happens, there is no consistent workaround
best bet is to just revert to a save before you added the mod that uses 0Harmony.dll, or try to remove unneeded mods to get the game to load faster.

EDIT: WORKAROUND FOUND!

Folow this handy dandy 3 step plan to load your save again

  1. load into a sandbox save with all mods EXCEPT the mod(s) that use 0Harmony.dll

  2. immediatly quit back to the title\

  3. load into your savegame

tested twice and it's working! if i have to guess doing it like this pre-cashes some data from the mods meaning the deserealization takes less time, and so harmony doesn't interrupt it!

Edit 3: alternate (faster) workaround

  1. click "new game"
  2. select the mods you want to use
  3. press continue and wait for the loading screen to leave
  4. back out to the main menu
  5. load your save

Attached files

I have attached 2 log files to this report
26-07-11_12-07-28_0191.log is from a crash, made to document this issue. The harmony interrupt happens at line 253.
26-07-10_16-05-22_9458.log is from a loaded game, the 1 instance where i got the mod that includes harmony to work, and i have no idea how. the harmony interrupt happens at line 667.

Edited 7 days ago
2 attachments only for board moderators
8 days ago

很简单,恳请你下载image.png
这些mod都会有Harmony 文件!
请你做一下比对.image.pngimage.png

很显然这个文件是作者自己编辑的,并非使用通用的版本.而这是被允许的,也是惯用的.同故障未能被我复现,我不能确定你的阐述是正确的,但是对你的反馈表示关注和感谢.
当然我也不能排除你提出的可能性是存在的,因为缺少必要的代码,可以知道作者自行编译的Harmony,是否具备卸载时同时卸载mod代码,也就是最后的卸载指令.
首先,我需要明确指出,感谢任何提出bug的朋友,你们的任何一次发声对任何mod制作者都是至关重要的,被尊重和理解,同时永远表示感谢和敬意.

其次,我们需要客观看待问题,而本问题不应该作为游戏的问题,而是mod的问题,应该在这个mod作者作品区域讨论.

另外,需要明确指出,这个mod作者非常肯定明确的表明是在测试阶段,其存在任何的可能性我们都应该予以谅解.

Harmony文件是可以被自行编译的,他是一个库,可以使用广泛流通的版本也可以作者自定义编译只要合适即可.
你不能用Harmony的问题来否定mod或者coi任何一方存在问题,当然我们也谨慎的保持客观的怀疑存在性.

现在的试验样本和参照数据是不完整不全面的,
你提供的报错截图可以看出一点,这个报错的类是游戏自身的顶部菜单图标引用报错,而因此我反而认为你游戏自身可能文件不完整.请你首先重新安装一次游戏再次重现这个故障,这是我中肯的提示.

It is clear that this file was edited by its author and is not a generic standard version, which is permitted and common practice. I have not been able to reproduce this same issue, so I cannot confirm that your explanation is accurate, though I acknowledge and appreciate your feedback.

That said, I cannot rule out the possibility you raised either. Due to the lack of relevant code, we cannot confirm whether the self-compiled Harmony library used by the author contains instructions to fully unload Mod code when the Mod is removed.

First off, I would like to express my gratitude to anyone who reports bugs. Every piece of feedback is invaluable to any Mod developer, and all reporters deserve full respect, understanding and sincere thanks.

Secondly, we need to view this issue objectively. This fault originates from the Mod rather than the base game, so related discussions should take place within the Mod author’s dedicated community section.

Additionally, it should be clarified that the Mod author has explicitly stated this work is still in testing phase. We should exercise reasonable understanding for any potential defects that may arise as a result.

Harmony is a library that developers may compile themselves; creators are free to use widely distributed official releases or custom-compiled builds as they see fit.

One should not use potential Harmony-related issues to assign fault to either the Mod itself or COI. At the same time, we maintain a neutral, cautious stance regarding any potential underlying problems.

The current test samples and reference data are incomplete and insufficient.

As can be seen from the error log screenshot you provided, the crash occurs within the base game’s top menu icon reference logic. This leads me to suspect the core game files themselves may be incomplete. My earnest suggestion is that you reinstall the full game and attempt to reproduce the error again.

7 days ago

thanks for the input wtmxhyy, i've run some more tests

also apologies in advance, i don't understand Chinese and used google translate to understand you

I verified my game files through steam's game file integrity checker before starting these tests, it didn't say i had any issues. Nor have i had this issue with my game before in the 2 months i've been playing it

you are correct that this is a mod issue, i attempted to recreate this with gameplay++, cheats++, and tweaks++ (i already had terrain designation) and was unable to do so.

I also tried to recreate this from a fresh save using the helicopter mod, and was also unable to do so

But, i was able to recreate it by going to an older save game and adding the mod through the load menu. meaning this isn't tied to a specific save game

So here's my theory:
CoI loads mods differently when starting a new game vs continuing a game. This is apparent as it takes a moment to pre-load mods from the new game menu, but doesn't when pressing continue or load. This discrepancy between load order causes this unique bug to appear due to a problem with the helicopter mod's specific build of harmony

While yes, this specific bug is entirely a mod issue, i still think it's worth addressing or at the very least investigating by the developers, as this difference in loading could cause other problems now or down the line

if you have any other ideas or thoughts, feel free to reply

7 days ago

i'd also like to note that cargo helecopters has been updated since i originally made this, i don't know if the bug is present on the newer versions so if you have problems recreating this issue use v 0.5.0

7 days ago

it seems the newer version of the helicopter mod has changed its harmony version, so this problem doesn't seem to exist anymore

But the fact it could have happened with the current game's code is notable

this issue can be considered resolved, yet i'd still implore the dev's to at least take a look at how mods/dlc are loaded to ensure a problem like this can't happen again. As i have mentioned there is a difference between loading a new game and loading a save game that caused this problem to pop up. Unifying the two methods would ensure no such problem could come up again. but that's just my 2 cents.

7 days ago

非常感谢回复,首先很遗憾我英文不好,也是用翻译工具,所以很可能词不达意.所以我都会用中文书写后再翻译,所以我中文发言后会有英文翻译版

Thank you very much for your reply. First of all, I regret that my English is poor and I have to rely on translation tools, so I may fail to express my ideas accurately. That's why I always write in Chinese first and then translate it, which is why there will be an English translated version following my Chinese remarks.

我也注意到这个mod已经更新,非常惊艳.他的模型设计让我拍案叫绝,这是一个奇思妙想的设计.

I've also noticed that this mod has been updated, and it's absolutely stunning. Its model design blows my mind; it's an incredibly ingenious creation.

当然,你提到的问题我非常关注,因为在理论上是存在的,这个游戏的序列化和加载顺序是的确会影响存档和加载的,这是客观的事实.

现在已知的影响存档的都是注册和反序列化问题,极少是其他逻辑代码引起加载故障.

Of course, I pay close attention to the issue you mentioned, because it theoretically exists. The serialization and loading order of this game does affect save file generation and game loading, which is an objective fact.

Currently, all known issues affecting save files stem from registration and deserialization problems, and loading failures are rarely caused by other logical codes.

注册建筑或者产品时,其加载顺序是严格的,首先是建筑其后才能是产品,只要产品被使用其母体上级使用的建筑必须首先注册.也就是有严格的上下级关联关系.

When registering buildings or items, their loading order is fixed: buildings must be loaded first, followed by items. If an item is to be used, its parent building at the upper level must be registered beforehand. In short, there is a strict hierarchical dependency relationship between them.

序列化用于存储,而读取档案需要反序列化,这个部分非常糟糕,极其引起问题.而官方也做了改进,相对以前已经是极大改善了.但是我认为依然希望官方能出台一个完善的可具备自定义的api,各种参数和配置修改值能够被自动序列化和反序列化那么将会自动适应.就好了.

Serialization is used for data storage, while deserialization is required for file reading. This mechanism is flawed and extremely prone to causing issues. The official team has made optimizations, bringing significant improvements compared with previous versions. However, I still hope the official team can launch a comprehensive and customizable API. If all modified parameters and configuration values can be automatically serialized and deserialized, the system will be able to adapt automatically, which would be ideal.

你提到的新建存档和旧存档加载存在差异,这是客观的.新mod一律使用新建存档的方式运行,这是普遍认识.

It is objective that there are differences between loading new save files and old save files as you mentioned. It is a common consensus that all new mods run with newly created save files.

有很多mod的设置配置注册等工作都在新建时候写入或者形成覆盖,如果加载旧存档是可能会跳过这部分初始化的.

Many mod setting, configuration and registration operations are written or overwritten when a new save file is created, and this part of the initialization process may be skipped when loading an old save file.

除非作者专门做了注册的延迟代码和校验代码,否则基本旧存档加载mod时不会触发再次注册,这是游戏机制和mod作者共同问题.Unless the author has specially written delayed registration code and verification code, re-registration will basically not be triggered when loading mods with old save files. This is a problem stemming from both the game mechanics and the mod authors.

因为,mod作者必须适应游戏开发框架在框架基础下做开发,而很多时候测试不足,测试周期远远大于开发周期.

Mod authors have to adapt to and develop based on the game development framework, yet testing is often insufficient, with the testing cycle far longer than the development cycle.

开发一个mod可能需要几天,而测试一个全局运行可能需要几个月.其中触发的各种可能性和各种其他mod适配都将会是一个极其艰巨的任务.Developing a mod may take several days, while testing its global operation can take several months. It is an extremely arduous task to account for all possible triggered scenarios and compatibility with various other mods.

感谢你提供宝贵的意见.Thank you for providing your valuable feedback.

👍 1
76 Showing 16 of 6
Log in to reply.