FilUnderscore / ImprovedHordes

7 Days To Die Server/Client Mod - Improves existing hordes by reworking their core behaviours.
https://community.7daystodie.com/topic/26781-improved-hordes/
Other
8 stars 3 forks source link

IH threading errors in debug build #23

Closed YakovAU closed 1 year ago

YakovAU commented 1 year ago

Hey. we'll be likely using IH in Ravenhearst, we use the debug build of 7d and i was wondering if you want those errors reported still as generally they dont show up in vanilla.

FilUnderscore commented 1 year ago

It would be helpful and much appreciated in terms of maintaining mod compatibility. I’ve seen quite a few using DF/Ravenhearst in combination with the mod.

YakovAU commented 1 year ago

heres the log information, it happens on a newgame in the debug build. Reading External Particles in ConfigFeatureBlock/ExternalParticles... Done Reading External Particles. 2023-09-06T01:50:23 1127.175 INF Started thread IH-ThreadSafeAStarPathFinder 2023-09-06T01:50:23 1127.233 INF [Improved Hordes] [ImprovedHordesCore] .ctor(Int32,ILoggerFactory,IRandomFactory`1,IEntitySpawner): Initializing. 2023-09-06T01:50:23 1127.268 INF Started thread IHThreaded-WorldEventReporter 2023-09-06T01:50:23 1127.269 INF Started thread IHThreaded-WorldHordeTracker 2023-09-06T01:50:23 1127.269 INF StartGame done 2023-09-06T01:50:23 1127.269 INF Started thread IHThreaded-WorldHordePopulator 2023-09-06T01:50:23 1127.269 ERR Exception in thread IHThreaded-WorldEventReporter: 2023-09-06T01:50:23 1127.269 ERR Exception in thread IHThreaded-WorldHordeTracker: 2023-09-06T01:50:23 1127.269 ERR Exception in thread IHThreaded-WorldHordePopulator: 2023-09-06T01:50:23 1127.273 EXC get_time can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. at (wrapper managed-to-native) UnityEngine.Time.get_time() at ImprovedHordes.Core.Threading.Threaded.ThreadLoop (ThreadManager+ThreadInfo threadInfo) [0x00014] in <545fd6ff8ed54acf9c76b226d604ce04>:0 at ThreadManager.myThreadInvoke (System.Object _threadInfo) [0x0005d] in :0 UnityEngine.StackTraceUtility:ExtractStringFromException(Object) Log:Exception(Exception) ThreadManager:myThreadInvoke(Object) System.Threading.ThreadHelper:ThreadStart_Context(Object) System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean) System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean) System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object) System.Threading.ThreadHelper:ThreadStart(Object)

2023-09-06T01:50:23 1127.273 EXC get_time can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. at (wrapper managed-to-native) UnityEngine.Time.get_time() at ImprovedHordes.Core.Threading.Threaded.ThreadLoop (ThreadManager+ThreadInfo threadInfo) [0x00014] in <545fd6ff8ed54acf9c76b226d604ce04>:0 at ThreadManager.myThreadInvoke (System.Object _threadInfo) [0x0005d] in :0 UnityEngine.StackTraceUtility:ExtractStringFromException(Object) Log:Exception(Exception) ThreadManager:myThreadInvoke(Object) System.Threading.ThreadHelper:ThreadStart_Context(Object) System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean) System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean) System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object) System.Threading.ThreadHelper:ThreadStart(Object)

2023-09-06T01:50:23 1127.273 INF Exited thread IHThreaded-WorldHordePopulator 2023-09-06T01:50:23 1127.273 INF Exited thread IHThreaded-WorldHordeTracker 2023-09-06T01:50:23 1127.273 EXC get_time can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. at (wrapper managed-to-native) UnityEngine.Time.get_time() at ImprovedHordes.Core.Threading.Threaded.ThreadLoop (ThreadManager+ThreadInfo threadInfo) [0x00014] in <545fd6ff8ed54acf9c76b226d604ce04>:0 at ThreadManager.myThreadInvoke (System.Object _threadInfo) [0x0005d] in :0 UnityEngine.StackTraceUtility:ExtractStringFromException(Object) Log:Exception(Exception) ThreadManager:myThreadInvoke(Object) System.Threading.ThreadHelper:ThreadStart_Context(Object) System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean) System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean) System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object) System.Threading.ThreadHelper:ThreadStart(Object)

2023-09-06T01:50:23 1127.273 INF Exited thread IHThreaded-WorldEventReporter 2023-09-06T01:50:23 1127.423 INF [Steamworks.NET] GameServer.Init successful 2023-09-06T01:50:23 1127.428 INF [Steamworks.NET] Making server public 2023-09-06T01:50:23 1127.429 INF Entering RefreshButtons Prefix 2023-09-06T01:50:23 1127.429 INF Buttons are not set to show. Deactivating. Calling Animator.GotoState on Synchronize layer 2023-09-06T01:50:24 1127.802 INF [EOS] Server registered, session: 1d45a8d26203492d824a3452c1a95b5f 2023-09-06T01:50:24 1127.805 INF [EOS] Session address: 159.196.149.228 2023-09-06T01:50:24 1127.810 INF [Steamworks.NET] Trying to create Lobby (visibility: k_ELobbyTypePublic) 2023-09-06T01:50:24 1128.148 INF [Steamworks.NET] Lobby creation succeeded, LobbyID=109775244366118067, server SteamID=, server public IP=15.19.14.22, server port=26900 2023-09-06T01:50:24 1128.155 INF [Steamworks.NET] Lobby entered: 109775244366118067 2023-09-06T01:50:24 1128.355 INF [Steamworks.NET] GameServer.LogOn successful, SteamID=90176095449852958, public IP=15.19.14.22 2023-09-06T01:50:24 1128.359 INF [Steamworks.NET] Exiting Lobby 2023-09-06T01:50:24 1128.359 INF [Steamworks.NET] Trying to create Lobby (visibility: k_ELobbyTypePublic) 2023-09-06T01:50:25 1128.710 INF [Steamworks.NET] Lobby creation succeeded, LobbyID=109775244366118082, server SteamID=90176095449852958, server public IP=15.19.14.22, server port=26900 2023-09-06T01:50:25 1128.713 INF [Steamworks.NET] Lobby entered: 109775244366118082 2023-09-06T01:50:26 1129.820 INF Respawn almost done 2023-09-06T01:50:26 1129.834 INF Chat (from '-non-player-', entity id '-1', to 'Global'): 'Improved Hordes': 2.0.0-beta.5 Experimental Build. 2023-09-06T01:50:26 1129.834 INF Chat (from '-non-player-', entity id '-1', to 'Global'): 'Improved Hordes': Please report any bugs/performance issues at github.com/FilUnderscore/ImprovedHordes/issues 2023-09-06T01:50:26 1129.840 INF PlayerSpawnedInWorld (reason: NewGame, position: -349, 35, 101): localplayer 2023-09-06T01:50:26 1129.873 INF 30290+1 Origin Reposition (0.0, 0.0, 0.0) to (-352.0, 32.0, 96.0) 2023-09-06T01:50:28 1132.006 INF MinEventLogMessage: XP gained during the last level: 2023-09-06T01:50:28 1132.006 INF CVarLogValue: $xpFromLootThisLevel == 0 2023-09-06T01:50:28 1132.006 INF CVarLogValue: $xpFromHarvestingThisLevel == 0 2023-09-06T01:50:28 1132.006 INF CVarLogValue: $xpFromKillThisLevel == 0 2023-09-06T01:50:29 1133.417 ERR Exception in thread IH-ThreadSafeAStarPathFinder: 2023-09-06T01:50:29 1133.418 EXC get_isPlaying can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. at (wrapper managed-to-native) UnityEngine.Application.get_isPlaying() at AstarPath.StartPath (Pathfinding.Path path, System.Boolean pushToFront) [0x000f3] in <75c8fe99ae854d1a97348f99c534fe45>:0 at GamePath.ASPPathFinder.Calculate (UnityEngine.Vector3 _fromPos, UnityEngine.Vector3 _toPos) [0x001cc] in :0 at GamePath.ASPPathNavigate.CreatePath () [0x00075] in :0 at GamePath.ASPPathNavigate.GetPathTo (GamePath.PathInfo _pathInfo) [0x0002a] in :0 at ImprovedHordes.ThreadSafeAStarPathFinderThread.LoopThread (ThreadManager+ThreadInfo threadInfo) [0x00069] in <545fd6ff8ed54acf9c76b226d604ce04>:0 at ThreadManager.myThreadInvoke (System.Object _threadInfo) [0x0005d] in :0 UnityEngine.StackTraceUtility:ExtractStringFromException(Object) Log:Exception(Exception) ThreadManager:myThreadInvoke(Object) System.Threading.QueueUserWorkItemCallback:System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() System.Threading.ThreadPoolWorkQueue:Dispatch() System.Threading._ThreadPoolWaitCallback:PerformWaitCallback()

2023-09-06T01:50:29 1133.418 INF Exited thread IH-ThreadSafeAStarPathFinder

FilUnderscore commented 1 year ago

Thanks for the log! Looks like Unity doesn't like stuff being accessed outside the main thread, odd that this is only occurring with the debug build.

YakovAU commented 1 year ago

we managed to catch a rare bug using the debug build, our splash screen would very rarely continue into the game, when we ran it on the debug build it popped a similar error and was consistent. Highly recommend using the debug build for development + rider IDE, the debugging tools in that are magic.

FilUnderscore commented 1 year ago

Try this build of the mod which makes some changes to threads depending on whether you're running a debug build. Hopefully Debug.isDebugBuild is set correctly and recognizes which build of the game you are running. I haven't currently got a debug build of the game up and running.

https://ci.filunderscore.com/job/ImprovedHordes/job/threading-fix/1/

I feel there might be a couple more issues with some other things that rely on accessing Time.time, but try out the build I've linked above and see if you catch any other errors.