TorchAPI / Torch

An extensible modding framework and improved client/DS for Space Engineers. Still a work in progress!
Apache License 2.0
146 stars 76 forks source link

TorchMod can cause Client crash (Thread unsafe access to GUI screens) #422

Closed LordTylus closed 2 years ago

LordTylus commented 3 years ago

Torch Version: 1.3.1.138 SE Version: 1.197.073

Expected Behavior

No error no client crash

Observed Behavior

Player joined the server and his client crashed.

After checking his ClientLogs (because server didnt show anything I just found a lot of

2020-12-27 11:02:30.495 - Thread:  30 ->  Processing message: IncomingMessage
2020-12-27 11:02:30.533 - Thread:  30 ->  Error: Thread unsafe access to GUI screens:    at Sandbox.Graphics.GUI.MyGuiScreenBase.CreateCloseButton()
   at Sandbox.Graphics.GUI.MyGuiScreenBase..ctor(Nullable`1 position, Nullable`1 backgroundColor, Nullable`1 size, Boolean isTopMostScreen, String backgroundTexture, Single backgroundTransition, Single guiTransition, Nullable`1 gamepadSlot)
   at Sandbox.Game.Gui.MyGuiScreenText..ctor(String missionTitle, String currentObjectivePrefix, String currentObjective, String description, Action`1 resultCallback, String okButtonCaption, Nullable`1 windowSize, Nullable`1 descSize, Boolean editEnabled, Boolean canHideOthers, Boolean enableBackgroundFade, MyMissionScreenStyleEnum style)
   at Sandbox.ModAPI.MyAPIUtilities.VRage.Game.ModAPI.IMyUtilities.ShowMissionScreen(String screenTitle, String currentObjectivePrefix, String currentObjective, String screenDescription, Action`1 callback, String okButtonCaption)
   at Torch.Mod.Messages.DialogMessage.ProcessClient()
   at Torch.Mod.ModCommunication.DoProcessing()
   at ParallelTasks.DelegateWork.DoWork(WorkData workData)
   at ParallelTasks.WorkItem.DoWork(Int32 expectedID)
   at ParallelTasks.BackgroundWorker.WorkLoop()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

exceptions Keen Log. Since its something triggered by Torch Mod as it seems it may be related to that.

Steps to Reproduce

đŸ¤· The player just joined the server.

Kevin03YZFR1 commented 3 years ago

I can also confirm this error is occurring on Torch version: 1.3.1.139 SE version: 1.197.075

Client side error log: 2021-02-02 07:54:32.892 - Thread: 67 -> Error: Thread unsafe access to GUI screens: at Sandbox.Graphics.GUI.MyGuiControls.Add(MyGuiControlBase control) at Sandbox.Game.Gui.MyGuiScreenText.RecreateControls(Boolean constructor) at Sandbox.Game.Gui.MyGuiScreenText..ctor(String missionTitle, String currentObjectivePrefix, String currentObjective, String description, Action1 resultCallback, String okButtonCaption, Nullable1 windowSize, Nullable1 descSize, Boolean editEnabled, Boolean canHideOthers, Boolean enableBackgroundFade, MyMissionScreenStyleEnum style) at Sandbox.ModAPI.MyAPIUtilities.VRage.Game.ModAPI.IMyUtilities.ShowMissionScreen(String screenTitle, String currentObjectivePrefix, String currentObjective, String screenDescription, Action1 callback, String okButtonCaption) at Torch.Mod.Messages.DialogMessage.ProcessClient() at Torch.Mod.ModCommunication.DoProcessing() at ParallelTasks.DelegateWork.DoWork(WorkData workData) at ParallelTasks.WorkItem.DoWork(Int32 expectedID) at ParallelTasks.BackgroundWorker.WorkLoop() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()

Kevin03YZFR1 commented 3 years ago

Update. This seems to be related to the Torch Essentials plugin. Deactivating "Client Join Tweaks" seems to have stabilized the problem.

Enabled settings were: Pack Respawn: Enabled Max Packed Respawn Size: 4000 Override Default Toolbar: Enabled Compression Level: Optimal Async Join: Enabled

More testing will be required to determine which setting exactly is causing the issue.

screwballl commented 3 years ago

Having same issue. I have full access to server on LAN, having same issue with my client on my server. Server error via Torch 1.3.1.152-master shows second connection attempt via IP 0.0.0.0 at time of client crash.

18:00:20.5741 [INFO] Keen: Peer2Peer_SessionRequest [007...215] 18:00:24.0478 [INFO] Keen: OnConnectedClient (username) attempt 18:00:24.2791 [INFO] MultiplayerManagerDedicated: Connection attempt by (steamid) from 192.168.1.48 18:00:24.3100 [INFO] MultiplayerManagerBase: Player (username)joined ((steamid)) 18:00:24.4179 [INFO] Keen: World request received: (username) 18:01:08.8927 [INFO] MultiplayerManagerDedicated: Connection attempt by (steamid)from 0.0.0.0 18:01:08.8927 [WARN] MultiplayerManagerDedicated: Player (steamid)has already joined! 18:01:08.9242 [INFO] Keen: User left (username) 18:01:08.9242 [INFO] MultiplayerManagerBase: (username) ((steamid)) Disconnected.

Played for a week on the planet with no problems. Problem occurs once a base is created in space. May be related to Industry DLC items created by said player since crash occurs after building Industry Refinery and/or assembler.

Lockeous commented 2 years ago

I see this issue is showing as 'Closed as Completed' but I'm not seeing a resolution. Has there been a published fix for this? This is the only issue raised on this topic, so updating this thread instead of creating new. Error from server is identical.

Torch Version: 1.3.1.195

14:50:24.7036 [INFO] Keen: Peer2Peer_SessionRequest [007...948] 14:50:28.5576 [INFO] Keen: OnConnectedClient (username) attempt 14:50:28.7573 [INFO] MultiplayerManagerDedicated: Connection attempt by (steamid) from 10.222.23.115 14:50:28.7739 [INFO] MultiplayerManagerBase: Player (username) joined ((steamid)) 14:50:28.8407 [INFO] Keen: World request received: (username) 14:53:56.5586 [INFO] MultiplayerManagerDedicated: Connection attempt by (steamid) from 0.0.0.0 14:53:56.5586 [WARN] MultiplayerManagerDedicated: Player (steamid) has already joined! 14:53:56.5646 [INFO] Keen: User left (username) 14:53:56.5646 [INFO] MultiplayerManagerBase: (username) ((steamid)) Disconnected. 14:54:11.6102 [INFO] Keen: Peer2Peer_ConnectionFailed [007...948], Timeout 14:54:11.6271 [INFO] Keen: User left [007...948] 14:54:11.6271 [INFO] MultiplayerManagerBase: [007...948] ((steamid)) Disconnected. 14:54:42.2445 [INFO] Keen: Autosave

My users are having no issue at all connecting to the server, everything from their perspective is working as intended. The only issue I'm seeing is my own client (connected via LAN) being unable to join.

screwballl commented 2 years ago

One workaround I found, which may only be related to my own setup, but I play at 2560x1440 resolution (and happens with any resolution above 1080). If I change the game to 1920x1080, join the server no issue, then change back to 2560x1440. It typically works for a few days before the issue reappears. I get the same issue but MUCH less frequently with vanilla game (1-2 weeks of no issues), with Torch it reappears within 1-3 days.