Valheim-Modding/Jotunn

[BUG] Jotunn.Managers.GUIManager.IsHeadless() crashes server when BepInEx.Configuration.ConfigFile.Reload()

nwesterhausen opened this issue · 4 comments

Details:
Jotunn Version: 2.3.7
Jotunn Submodule(if applicable): SynchronizationManager then GUIManager
Repeatability(Consistent(100%), Inconsistent(50%), Rare(1%), Unknown(==1)): Consistent

Problem Description:
Having a ConfigFile reference, then calling ConfigFIle.Reload() should reload the values in the configuration file. Instead the server crashes if Jotunn is a loaded mod.

I can make this happen myself by doing the following after the server is running:

SystemInfo.graphicsDeviceType == GraphicsDeviceType.Null

Calling that during Awake() doesn't cause any problems, but seems like it does cause a problem after the server is running. This value should not change for the duration of the running process, so maybe it can be cached instead.

Expected Behaviour:
Calling ConfigFile.Reload() to reload the config file without a crash. (And this happens when Jotunn is not loaded.)

Actual Behaviour:
Hard crash (excerpt):

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) UnityEngine.SystemInfo.GetGraphicsDeviceType () [0x00000] in <30e538f3cf5548cfa6abc9730778bcef>:0
  at UnityEngine.SystemInfo.get_graphicsDeviceType () [0x00001] in <30e538f3cf5548cfa6abc9730778bcef>:0
  at Jotunn.Managers.GUIManager.IsHeadless () [0x00000] in <e3b57af5621d4e20bda0bd5421a59138>:0
  at Jotunn.Managers.SynchronizationManager/ConfigEntryBase_SetSerializedValue.Prefix (BepInEx.Configuration.ConfigEntryBase,string) [0x00000] in <e3b57af5621d4e20bda0bd5421a59138>:0
  at (wrapper dynamic-method) BepInEx.Configuration.ConfigEntryBase.DMD<BepInEx.Configuration.ConfigEntryBase..SetSerializedValue> (BepInEx.Configuration.ConfigEntryBase,string) [0x00017] in <73d37a760d5a4444be8d7989b489dc1a>:0
  at BepInEx.Configuration.ConfigFile.Reload () [0x000cc] in <73d37a760d5a4444be8d7989b489dc1a>:0
  at DiscordConnector.Config.MainConfig.ReloadConfig () [0x00001] in <2a7b7feceb914b788c244891582bb637>:0

How to replicate
Have a loaded plugin create a ConfigFile and keep the reference, then at a later point call Reload() on that reference.

Link to your server's and client's LogOutput.log
Since the LogOutput.log didn't have the entire log because of the crash, I manually copied from the console output into a log file (attached). Debug logging is on.

ManualFullLog.log

Thanks for the report. Can you test if this build fixes it: https://github.com/Valheim-Modding/Jotunn/actions/runs/1376916155

Tested that version and confirm that the crash does not happen.

Particularly strange that one. I have other mods using that technique (Config.Reload()) to trigger config syncs and at least my local dedicated does not crash (Win64). Did not test the Linux dedicated for that particular behaviour, but never had a hard crash there either. Anyway, next version will have the fix.

Thanks!