Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant game crashes #2

Open
V10lator opened this issue Nov 27, 2023 · 3 comments
Open

Constant game crashes #2

V10lator opened this issue Nov 27, 2023 · 3 comments

Comments

@V10lator
Copy link

I have a savegame here which crashes after around a minute after loading with the mod enabled. No crash w/o the mod.

Crashlog:

[Error  : Unity Log] [SceneFlow] [CRITICAL]  System update error during GameSimulation System.NullReferenceException: Object reference not set to an instance of an object
  at Unity.Entities.EntityComponentStore.InsertSharedComponent_Unmanaged (Unity.Entities.TypeIndex typeIndex, System.Int32 hashCode, System.Void* data, System.Void* defaultValue) [0x000e5] in <9823f950a18a49a1a4ada101a5698c63>:0 
  at Unity.Entities.EntityDataAccess.InsertSharedComponent_Unmanaged[T] (T newData) [0x0002f] in <9823f950a18a49a1a4ada101a5698c63>:0 
  at Unity.Entities.EntityQueryImpl.AddSharedComponentFilterUnmanaged[SharedComponent] (SharedComponent sharedComponent) [0x00064] in <9823f950a18a49a1a4ada101a5698c63>:0 
  at Unity.Entities.EntityQueryImpl.SetSharedComponentFilterUnmanaged[SharedComponent1] (SharedComponent1 sharedComponent1) [0x00006] in <9823f950a18a49a1a4ada101a5698c63>:0 
  at Unity.Entities.EntityQuery.SetSharedComponentFilter[SharedComponent] (SharedComponent sharedComponent) [0x00006] in <9823f950a18a49a1a4ada101a5698c63>:0 
  at Game.Simulation.CarNavigationSystem.OnUpdate () [0x00026] in <1f030b0a20a34c92a53f8d33297505a2>:0 
  at Unity.Entities.SystemBase.Update () [0x0004e] in <9823f950a18a49a1a4ada101a5698c63>:0 
  at Game.UpdateSystem.Update (Game.SystemUpdatePhase phase, System.UInt32 updateIndex, System.Int32 iterationIndex) [0x0007a] in <1f030b0a20a34c92a53f8d33297505a2>:0 

Complete LogOutput.txt (with Unity Log redirection enabled in BepInEx) :

[Message:   BepInEx] BepInEx 5.4.22.0 - Cities2 (20.11.2023 10:51:36)
[Info   :   BepInEx] Running under Unity v2022.3.7.9732149
[Info   :   BepInEx] CLR runtime version: 4.0.30319.42000
[Info   :   BepInEx] Supports SRE: True
[Info   :   BepInEx] System platform: Bits64, Windows
[Message:   BepInEx] Preloader started
[Info   :   BepInEx] Loaded 1 patcher method from [BepInEx.Preloader 5.4.22.0]
[Info   :   BepInEx] 1 patcher plugin loaded
[Info   :   BepInEx] Patching [UnityEngine.CoreModule] with [BepInEx.Chainloader]
[Message:   BepInEx] Preloader finished
[Message:   BepInEx] Chainloader ready
[Message:   BepInEx] Chainloader started
[Info   :   BepInEx] 1 plugin to load
[Info   :   BepInEx] Loading [BetterPedestrianPathfind 0.0.1]
[Info   :BetterPedestrianPathfind] Plugin BetterPedestrianPathfind is loaded!
[Message:   BepInEx] Chainloader startup complete
[Info   :   Console] Logs at C:/users/steamuser/AppData/LocalLow/Colossal Order/Cities Skylines II/Logs
[Info   : Unity Log] Game version: 1.0.14f1 (135.24916) [5275.25758]
[Info   : Unity Log] Type: Desktop
OS: Windows 10  (10.0.19043) 64bit
System memory: 31,241 GB
Graphics device: AMD Radeon RX 580 Series (RADV POLARIS10) (Version: Direct3D 11.0 [level 11.1])
Graphics memory: 8,000 GB
Max texture size: 16384
Shader level: 50
3D textures: True
Shadows: True
Compute: True
CPU: AMD FX(tm)-8350 Eight-Core Processor
Core count: 8
Platform: WindowsPlayer
Screen resolution: 1920x1080x60
Window resolution: 1920x1080
DPI: 96
Rendering Threading Mode: LegacyJobified
CLR: 4.0.30319.42000
Scripting runtime: Mono 6.13.0 (Visual Studio built mono)
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   :BetterPedestrianPathfind] Override PedestrianPathfind called
[Info   : Unity Log] Found water here : 898, 425
[Info   : Unity Log] Found water here : 903, 420
[Info   : Unity Log] Found water here : 903, 414
[Info   : Unity Log] Found water here : 904, 413
[Info   : Unity Log] Found water here : 905, 412
[Info   : Unity Log] Found water here : 902, 408
[Info   : Unity Log] Found water here : 902, 408
[Info   : Unity Log] Found water here : 897, 398
[Info   : Unity Log] Found water here : 894, 392
[Info   : Unity Log] Found water here : 893, 393
[Info   : Unity Log] Found water here : 899, 408
[Error  : Unity Log] [SceneFlow] [CRITICAL]  System update error during GameSimulation System.NullReferenceException: Object reference not set to an instance of an object
  at Unity.Entities.EntityComponentStore.InsertSharedComponent_Unmanaged (Unity.Entities.TypeIndex typeIndex, System.Int32 hashCode, System.Void* data, System.Void* defaultValue) [0x000e5] in <9823f950a18a49a1a4ada101a5698c63>:0 
  at Unity.Entities.EntityDataAccess.InsertSharedComponent_Unmanaged[T] (T newData) [0x0002f] in <9823f950a18a49a1a4ada101a5698c63>:0 
  at Unity.Entities.EntityQueryImpl.AddSharedComponentFilterUnmanaged[SharedComponent] (SharedComponent sharedComponent) [0x00064] in <9823f950a18a49a1a4ada101a5698c63>:0 
  at Unity.Entities.EntityQueryImpl.SetSharedComponentFilterUnmanaged[SharedComponent1] (SharedComponent1 sharedComponent1) [0x00006] in <9823f950a18a49a1a4ada101a5698c63>:0 
  at Unity.Entities.EntityQuery.SetSharedComponentFilter[SharedComponent] (SharedComponent sharedComponent) [0x00006] in <9823f950a18a49a1a4ada101a5698c63>:0 
  at Game.Simulation.CarNavigationSystem.OnUpdate () [0x00026] in <1f030b0a20a34c92a53f8d33297505a2>:0 
  at Unity.Entities.SystemBase.Update () [0x0004e] in <9823f950a18a49a1a4ada101a5698c63>:0 
  at Game.UpdateSystem.Update (Game.SystemUpdatePhase phase, System.UInt32 updateIndex, System.Int32 iterationIndex) [0x0007a] in <1f030b0a20a34c92a53f8d33297505a2>:0 
@V10lator
Copy link
Author

Forget to say: It doesn't always produce a crashlog. Also sometimes the game just freezes, sometimes this pops up:
image
And sometimes this:
image
(sorry about the bad quality shot)

@V10lator
Copy link
Author

V10lator commented Nov 27, 2023

Tried to rewrite Patches.cs to this:

using Game.Prefabs;
using HarmonyLib;
using System.Runtime.InteropServices;
using Unity.Entities;

namespace BetterPedestrianPathfind;

[HarmonyPatch]
class Patches
{
    [HarmonyPatch(typeof(PedestrianPathfind), "Initialize")]
    [HarmonyPrefix]
    static bool Prefix(ref EntityManager entityManager, ref Entity entity, PedestrianPathfind __instance) {
        Logger.LogInfo("Override PedestrianPathfind called");

        PathfindPedestrianData componentData = default(PathfindPedestrianData);
        GCHandle gch = GCHandle.Alloc(componentData); // TODO: Unpin

        componentData.m_WalkingCost = new PathfindCostInfo(0f, 0f, 0f, 0.01f).ToPathfindCosts();
        componentData.m_CrosswalkCost = new PathfindCostInfo(0f, 0f, 0f, 5f).ToPathfindCosts();
        componentData.m_UnsafeCrosswalkCost = new PathfindCostInfo(0f, 1000f, 0f, 5f).ToPathfindCosts();
        componentData.m_SpawnCost = new PathfindCostInfo(5f, 0f, 0f, 0f).ToPathfindCosts();

        entityManager.SetComponentData(entity, componentData);
 //       GCHandle.Free(gch); // TODO: Too early?
        return false;
    }
}

Can't test through as I don't know where to get the missing assembly Visual Studio complains about. So if you could compile this (maybe two times: One time like it is here and one time with the commented out line uncommented) and handle the result(s) over to me I could do some testing. :)

Note that I'm not 100% sure it will compile through: I'm not that familiar with C# / .NET, esp. not with its garbage collector.

V10lator added a commit to V10lator/Cities2-Mods that referenced this issue Nov 27, 2023
…static, so the GC will never remove them. It also renames them to seperate them from game variables.

This fixes thardie#2
@V10lator
Copy link
Author

Managed to compile and saw the real issue when comparing with game codes. Confirmed the fix with my bug triggering savegame and opened a PR. :)

V10lator added a commit to V10lator/Cities2-Mods that referenced this issue Nov 27, 2023
…static, so the GC will never remove them. It also renames them to seperate them from game variables.

This fixes thardie#2
V10lator added a commit to V10lator/Cities2-Mods that referenced this issue Nov 28, 2023
…static, so the GC will never remove them. It also renames them to seperate them from game variables.

This fixes thardie#2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant