Space Engineers

Space Engineers

[VSI] Emissive Controls
Digi 10 May, 2018 @ 8:11pm
Severe issues with this mod's gamelogic hijacking
Other mods that attach gamelogic to blocks will have their updates called after the block is removed and after the world is reloaded or even changed.

This seems to be particularily caused by your mod's gamelogic hijack combined with the other mod setting NeedsUpdate after Init.

I hope you can understand how many issues that causes, ranging from weird errors/crashes to severe performance hits.

Try it:
1. Make another local mod with this: https://pastebin.com/UZ6fmaDr
2. Load a creative world with this mod and the mod with the above code.
3. Place an advanced rotor and immediately remove it.
4. Open SpaceEngineers.log and see how it still updates after it's been removed.
5. Exit to menu and create a new empty world, no need to do anything in that world.
6. See SE log again, it still updates the block from the previous world.
< >
Showing 1-15 of 17 comments
Darkmist  [developer] 13 May, 2018 @ 3:16am 
Thanks for taking the time to write this. I'll take a look at it and will try to come up something more robust if possible
Darkmist  [developer] 13 May, 2018 @ 4:00am 
So yeah, I found the problem. I never actually called the necessary lifecycle methods on the wrapped game logic, so it basically remained registered for update.

Thank you again for letting me know. I have pushed an update and tested it with your "test mod". It stopped updating correctly after removal.
q_antum 24 May, 2018 @ 6:13pm 
Hello Darkmist, I have beed doing som bug hunting recently with a couple mods that have not been working while emissive controls has been installed. Nuke's tractor beam and Phoenix's beam drill and even Digi's build info have been causing some weird stuff like custom ui controlls not showing up or just not working. It wasnt untill using jubbajubbjubb's auto scrol lcd scirpt that I encountered a ctd citing emissive controls. Removing your mod restores the others to normal(just having the mod installed it seems causes these issues). Here's the last bit of the log file from the crashes. I hope it helps.

--------------------------------
2018-05-24 20:45:54.973 - Thread: 1 -> GC Memory: 1,946,503,360 B
2018-05-24 20:46:10.581 - Thread: 1 -> Exception occured: System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at DarkVault.EmissiveControl.EmissiveControlLogic.ParseCustomData(Dictionary`2& settings)
at DarkVault.EmissiveControl.EmissiveControlLogic.OnCustomDataChanged(IMyTerminalBlock block)
at Sandbox.Game.Entities.Cube.MyTerminalBlock.SetCustomData_Internal(String value, Boolean sync)
at lambda_method(Closure , MyTerminalBlock , String , DBNull , DBNull , DBNull , DBNull , DBNull )
at VRage.Network.MyReplicationLayerBase.InvokeLocally[T1,T2,T3,T4,T5,T6,T7](CallSite`7 site, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
at VRage.Network.MyReplicationSingle.DispatchEvent[T1,T2,T3,T4,T5,T6,T7,T8](CallSite callSite, EndpointId recipient, Single unreliablePriority, T1& arg1, T2& arg2, T3& arg3, T4& arg4, T5& arg5, T6& arg6, T7& arg7, T8& arg8)
at VRage.Network.MyReplicationLayerBase.RaiseEvent[T1,T2,T3](T1 arg1, T3 arg3, Func`2 action, T2 arg2, EndpointId endpointId, Single unreliablePriority)
at Sandbox.Game.Entities.Cube.MyTerminalBlock.RaiseCustomDataChanged()
at Sandbox.Game.Entities.Cube.MyTerminalBlock.SetCustomData_Internal(String value, Boolean sync)
at Sandbox.Game.Entities.Cube.MyTerminalBlock.CloseWindow()
at Sandbox.Game.Gui.MyGuiScreenText.CallResultCallback(ResultEnum result)
at Sandbox.Game.Gui.MyGuiScreenText.CloseScreen()
at Sandbox.Graphics.GUI.MyGuiControlButton.HandleInput()
at Sandbox.Graphics.GUI.MyGuiScreenBase.HandleControlsInput(Boolean receivedFocusInThisUpdate)
at Sandbox.Graphics.GUI.MyGuiScreenBase.HandleInput(Boolean receivedFocusInThisUpdate)
at Sandbox.Graphics.GUI.MyScreenManager.HandleInput()
at Sandbox.Graphics.GUI.MyDX9Gui.HandleInput()
at Sandbox.MySandboxGame.Update()
at Sandbox.Engine.Platform.Game.UpdateInternal()
at Sandbox.Engine.Platform.Game.RunSingleFrame()
at Sandbox.Engine.Platform.FixedLoop.<>c__DisplayClass1.<Run>b__0()
at Sandbox.Engine.Platform.GenericLoop.Run(VoidAction tickCallback)
at Sandbox.Engine.Platform.Game.RunLoop()
at Sandbox.MySandboxGame.Run(Boolean customRenderLoop, Action disposeSplashScreen)
at SpaceEngineers.MyProgram.Main(String[] args)
2018-05-24 20:46:10.583 - Thread: 1 -> Hiding window
2018-05-24 20:46:10.583 - Thread: 1 -> Hiding window done
2018-05-24 20:46:10.583 - Thread: 1 -> Showing message
Darkmist  [developer] 25 May, 2018 @ 4:48pm 
Hi q_antum,

Thank you for the log. That definitely helps. I am going to check the problem.
Darkmist  [developer] 26 May, 2018 @ 5:37am 
So the crash shown in the log you have posted was caused because the AutoScroll config in the block's CustomData had a format EmissiveControl was not able to parse or ignore. I have changed the parse code to be more robust.

As for the other mods not working, I also rewrote the logic of the mode to be a lot less intrusive which will hopefully result in a lot less of these unforeseen side effects.

I am not sure how Build Info was not working, but I was able to track down the problem by testing with the Tractor Beam mod. Now that seems to be working. If you still encounter problems with those other mods, please let me know. An exact description of the error per mod would help a lot in case you find more bugs.
q_antum 26 May, 2018 @ 1:13pm 
Awesome! I have both build info and emissive controls installed on a test world with the tractor mod and there is no issue now. Glad to have helped. I have no idea how build info was related either but the tractor's custom ui just wouldn't show up with it installed along side emissive controls. Removing either one though it would work just fine.
q_antum 26 May, 2018 @ 5:11pm 
Ok, one more crash log for you. I'm not sure that this was an intended use but, playing in creative I had aplied the emissive override tag to a gravity generator(copied from a beacon) and then removed it with right click. The crash occurs every time I do this. Grinding down the generator does not produce the crash though.

*edit*
This also sometimes occurs when bumping the emissive value above 1 to get a brighter texture and then accepting the change in the custom data box. I have used it set at 15 for many other blocks even modded ones. Sometimes it crashes someitmes it doesn't.
----------------
2018-05-26 20:01:02.782 - Thread: 1 -> Exception occured: System.NullReferenceException: Object reference not set to an instance of an object.
at DarkVault.EmissiveControl.EmissiveControlLogic.CheckEmissiveOverride()
at DarkVault.EmissiveControl.EmissiveControlLogic.UpdateOnceBeforeFrame()
at VRage.Game.Components.MyGameLogicComponent.VRage.Game.Entity.EntityComponents.Interfaces.IMyGameLogicComponent.UpdateOnceBeforeFrame(Boolean entityUpdate)
at VRage.Game.Entity.MyGameLogic.UpdateOnceBeforeFrame()
at VRage.Game.Entity.MyGameLogic.UpdateBeforeSimulation()
at Sandbox.Game.World.MySector.UpdateBeforeSimulation()
at Sandbox.Game.World.MySession.UpdateComponents()
at Sandbox.Game.World.MySession.Update(MyTimeSpan updateTime)
at Sandbox.MySandboxGame.Update()
at Sandbox.Engine.Platform.Game.UpdateInternal()
at Sandbox.Engine.Platform.Game.RunSingleFrame()
at Sandbox.Engine.Platform.FixedLoop.<>c__DisplayClass1.<Run>b__0()
at Sandbox.Engine.Platform.GenericLoop.Run(VoidAction tickCallback)
at Sandbox.Engine.Platform.Game.RunLoop()
at Sandbox.MySandboxGame.Run(Boolean customRenderLoop, Action disposeSplashScreen)
at SpaceEngineers.MyProgram.Main(String[] args)
2018-05-26 20:01:02.784 - Thread: 1 -> Hiding window
2018-05-26 20:01:02.784 - Thread: 1 -> Hiding window done
2018-05-26 20:01:02.784 - Thread: 1 -> Showing message
Last edited by q_antum; 26 May, 2018 @ 5:22pm
q_antum 26 May, 2018 @ 5:42pm 
And again when blowing up a group of reactors with a warhead.

--------------

2018-05-26 20:38:35.751 - Thread: 1 -> GC Memory: 965,401,800 B
2018-05-26 20:38:40.900 - Thread: 1 -> Exception occured: System.NullReferenceException: Object reference not set to an instance of an object.
at DarkVault.EmissiveControl.EmissiveControlLogic.CheckEmissiveOverride()
at DarkVault.EmissiveControl.EmissiveControlLogic.UpdateOnceBeforeFrame()
at VRage.Game.Components.MyGameLogicComponent.VRage.Game.Entity.EntityComponents.Interfaces.IMyGameLogicComponent.UpdateOnceBeforeFrame(Boolean entityUpdate)
at VRage.Game.Entity.MyGameLogic.UpdateOnceBeforeFrame()
at VRage.Game.Entity.MyGameLogic.UpdateBeforeSimulation()
at Sandbox.Game.World.MySector.UpdateBeforeSimulation()
at Sandbox.Game.World.MySession.UpdateComponents()
at Sandbox.Game.World.MySession.Update(MyTimeSpan updateTime)
at Sandbox.MySandboxGame.Update()
at Sandbox.Engine.Platform.Game.UpdateInternal()
at Sandbox.Engine.Platform.Game.RunSingleFrame()
at Sandbox.Engine.Platform.FixedLoop.<>c__DisplayClass1.<Run>b__0()
at Sandbox.Engine.Platform.GenericLoop.Run(VoidAction tickCallback)
at Sandbox.Engine.Platform.Game.RunLoop()
at Sandbox.MySandboxGame.Run(Boolean customRenderLoop, Action disposeSplashScreen)
at SpaceEngineers.MyProgram.Main(String[] args)
2018-05-26 20:38:40.904 - Thread: 1 -> Hiding window
2018-05-26 20:38:40.904 - Thread: 1 -> Hiding window done
2018-05-26 20:38:40.904 - Thread: 1 -> Showing message
Darkmist  [developer] 27 May, 2018 @ 3:08am 
Thank you! I actually tested removing by right click, but it was a space ball. I'll check with the gravity generator. Null reference should not occur for values higher than 1 I think, but I'll think about that too.
Darkmist  [developer] 27 May, 2018 @ 5:05am 
Ok, so there was some weird stuff going on with the registration for updates. I still don't understand how this was possible, but I think I have found a way to prevent it.

As for the emissivity value, it should be between 0 and 1. I am not clamping it now, but use at your own risk. If at some point the engine decides to crash, just know that it's not supposed to be greater than 1. However I am pretty sure, the problem you described above doesn't have to do anything with it.
q_antum 27 May, 2018 @ 6:47pm 
Great! Thanks for the support. Even with the higher emissive values everything seems to be working as intended. I've done some more testing though and there still seems to be an issue with the auto scroll script. If I want to bump the emissive values over 1 I need to stop the script's timer else, it crashes the game. The script itself is a bit old so that probably has something to do with it. Seeing as how I was pushing the emissive values(nothing seems to change visually after a value of 2500 if you're curious) I'm also not surprised. But here is that log if you're interested.

---------

2018-05-27 21:27:42.008 - Thread: 1 -> GC Memory: 1,193,358,776 B
2018-05-27 21:27:50.889 - Thread: 1 -> Exception occured: System.FormatException: Input string was not in a correct format.
at System.Number.ParseSingle(String value, NumberStyles options, NumberFormatInfo numfmt)
at DarkVault.EmissiveControl.EmissiveControlLogic.OnCustomDataChanged(IMyTerminalBlock block)
at Sandbox.Game.Entities.Cube.MyTerminalBlock.SetCustomData_Internal(String value, Boolean sync)
at lambda_method(Closure , MyTerminalBlock , String , DBNull , DBNull , DBNull , DBNull , DBNull )
at VRage.Network.MyReplicationLayerBase.InvokeLocally[T1,T2,T3,T4,T5,T6,T7](CallSite`7 site, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
at VRage.Network.MyReplicationSingle.DispatchEvent[T1,T2,T3,T4,T5,T6,T7,T8](CallSite callSite, EndpointId recipient, Single unreliablePriority, T1& arg1, T2& arg2, T3& arg3, T4& arg4, T5& arg5, T6& arg6, T7& arg7, T8& arg8)
at VRage.Network.MyReplicationLayerBase.RaiseEvent[T1,T2,T3](T1 arg1, T3 arg3, Func`2 action, T2 arg2, EndpointId endpointId, Single unreliablePriority)
at Sandbox.Game.Entities.Cube.MyTerminalBlock.RaiseCustomDataChanged()
at Sandbox.Game.Entities.Cube.MyTerminalBlock.SetCustomData_Internal(String value, Boolean sync)
at Sandbox.Game.Entities.Cube.MyTerminalBlock.CloseWindow()
at Sandbox.Game.Gui.MyGuiScreenText.CallResultCallback(ResultEnum result)
at Sandbox.Game.Gui.MyGuiScreenText.CloseScreen()
at Sandbox.Graphics.GUI.MyGuiControlButton.HandleInput()
at Sandbox.Graphics.GUI.MyGuiScreenBase.HandleControlsInput(Boolean receivedFocusInThisUpdate)
at Sandbox.Graphics.GUI.MyGuiScreenBase.HandleInput(Boolean receivedFocusInThisUpdate)
at Sandbox.Graphics.GUI.MyScreenManager.HandleInput()
at Sandbox.Graphics.GUI.MyDX9Gui.HandleInput()
at Sandbox.MySandboxGame.Update()
at Sandbox.Engine.Platform.Game.UpdateInternal()
at Sandbox.Engine.Platform.Game.RunSingleFrame()
at Sandbox.Engine.Platform.FixedLoop.<>c__DisplayClass1.<Run>b__0()
at Sandbox.Engine.Platform.GenericLoop.Run(VoidAction tickCallback)
at Sandbox.Engine.Platform.Game.RunLoop()
at Sandbox.MySandboxGame.Run(Boolean customRenderLoop, Action disposeSplashScreen)
at SpaceEngineers.MyProgram.Main(String[] args)
2018-05-27 21:27:50.891 - Thread: 1 -> Hiding window
2018-05-27 21:27:50.891 - Thread: 1 -> Hiding window done
2018-05-27 21:27:50.891 - Thread: 1 -> Showing message
Darkmist  [developer] 1 Jun, 2018 @ 1:49am 
Yeah, unfortunately a lot of LCD scripts use CustomData for configuration and it's kind of hard to make sure that what you expect there for your config doesn't interfere with theirs and vica versa, so after some though I decided to simply leave LCDs alone. There probably won't be too much emissive to override anyways.

Let me know if this solved your issue with AutoScroll.
theBradGuy 21 Sep, 2019 @ 1:33pm 
I just had my server in a crash loop on restart, after a perfectly normal restart triggered. This is all I could find in reference to my crash log. Not sure if its entirely related, but this seemed to be the most appropriate place to ask for help.

15:13:57.2320 [FATAL] Initializer: System.InvalidOperationException: Collection was modified; enumeration operation may not execute. at System.Collections.Generic.HashSet`1.Enumerator.MoveNext() at Sandbox.Game.Entities.MyCubeGrid.VRage.Game.ModAPI.IMyCubeGrid.GetBlocks(List`1 blocks, Func`2 collect) at DarkVault.EmissiveControl.EmissiveControlGridLogic.OnPlayerLeftCockpit(String entityName, Int64 playerId, String gridName) at Sandbox.Game.DoubleKeyPlayerEvent.Invoke(String entityName, Int64 playerId, String gridName) at Sandbox.Game.Entities.MyCockpit.RemovePilot() at Sandbox.Game.Entities.MyCockpit.OnRemovedFromScene(Object source) at VRage.Game.Components.MyHierarchyComponentBase.RemoveChild(IMyEntity child, Boolean preserveWorldPos) at Sandbox.Game.Entities.MyCubeGrid.MoveBlocks(MyCubeGrid from, MyCubeGrid to, List`1 cubeBlocks, Int32 offset, Int32 count) at Sandbox.Game.Entities.MyCubeGrid.CreateSplitForGroup(MyCubeGrid originalGrid, List`1 splitBlocks, Group& group) at Sandbox.Game.Entities.MyCubeGrid.CreateSplits(MyCubeGrid originalGrid, List`1 splitBlocks, List`1 groups, MyTestDisconnectsReason reason, Boolean sync) at Sandbox.Game.Entities.Cube.MyDisconnectHelper.Disconnect(MyCubeGrid grid, MyTestDisconnectsReason reason, MySlimBlock testBlock, Boolean testDisconnect) at Sandbox.Game.Entities.MyCubeGrid.DetectDisconnects() at Sandbox.Game.Entities.MyCubeGrid.DoLazyUpdates() at Sandbox.Game.Entities.MyCubeGrid.UpdateBeforeSimulation() at Patched_Sandbox.Game.Entities.MyEntities+<>c<UpdateBeforeSimulation>b__110_0_0(Object , MyEntity ) at VRage.Collections.MyDistributedUpdater`2.Iterate(Action`1 p) at Sandbox.Game.Entities.MyEntities.UpdateBeforeSimulation() at Sandbox.Game.World.MySector.UpdateBeforeSimulation() at Patched_Sandbox.Game.World.MySessionUpdateComponents_0(Object ) at Sandbox.Game.World.MySession.Update(MyTimeSpan updateTime) at Sandbox.MySandboxGame.Update() at Sandbox.Engine.Platform.Game.UpdateInternal() at Patched_Sandbox.Engine.Platform.GameRunSingleFrame_0(Object ) at Sandbox.Engine.Platform.FixedLoop.<>c__DisplayClass11_0.<Run>b__0() at Sandbox.Engine.Platform.GenericLoop.Run(VoidAction tickCallback) at Sandbox.Engine.Platform.Game.RunLoop() at Sandbox.MySandboxGame.Run(Boolean customRenderLoop, Action disposeSplashScreen) at Torch.VRageGame.DoStart() in C:\jenkins\workspace\Torch_Torch_master\Torch\ViewModels\ViewModel.cs:line 62 at Torch.VRageGame.Run() 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() System.InvalidOperationException: Collection was modified; enumeration operation may not execute. at System.Collections.Generic.HashSet`1.Enumerator.MoveNext() at Sandbox.Game.Entities.MyCubeGrid.VRage.Game.ModAPI.IMyCubeGrid.GetBlocks(List`1 blocks, Func`2 collect) at DarkVault.EmissiveControl.EmissiveControlGridLogic.OnPlayerLeftCockpit(String entityName, Int64 playerId, String gridName) at Sandbox.Game.DoubleKeyPlayerEvent.Invoke(String entityName, Int64 playerId, String gridName) at Sandbox.Game.Entities.MyCockpit.RemovePilot() at Sandbox.Game.Entities.MyCockpit.OnRemovedFromScene(Object source) at VRage.Game.Components.MyHierarchyComponentBase.RemoveChild(IMyEntity child, Boolean preserveWorldPos) at Sandbox.Game.Entities.MyCubeGrid.MoveBlocks(MyCubeGrid from, MyCubeGrid to, List`1 cubeBlocks, Int32 offset, Int32 count) at Sandbox.Game.Entities.MyCubeGrid.CreateSplitForGroup(MyCubeGrid originalGrid, List`1 splitBlocks, Group& group) at Sandbox.Game.Entities.MyCubeGrid.CreateSplits(MyCubeGrid originalGrid, List`1 splitBlocks, List`1 groups, MyTestDisconnectsReason reason, Boolean sync) at Sandbox.Game.Entities.Cube.MyDisconnectHelper.Disconnect(MyCubeGrid grid, MyTestDisconnectsReason reason, MySlimBlock testBlock, Boolean testDisconnect) at Sandbox.Game.Entities.MyCubeGrid.DetectDisconnects() at Sandbox.Game.Entities.MyCubeGrid.DoLazyUpdates() at Sandbox.Game.Entities.MyCubeGrid.UpdateBeforeSimulation() at Patched_Sandbox.Game.Entities.MyEntities+<>c<UpdateBeforeSimulation>b__110_0_0(Object , MyEntity ) at VRage.Collections.MyDistributedUpdater`2.Iterate(Action`1 p) at Sandbox.Game.Entities.MyEntities.UpdateBeforeSimulation() at Sandbox.Game.World.MySector.UpdateBeforeSimulation() at Patched_Sandbox.Game.World.MySessionUpdateComponents_0(Object ) at Sandbox.Game.World.MySession.Update(MyTimeSpan updateTime) at Sandbox.MySandboxGame.Update() at Sandbox.Engine.Platform.Game.UpdateInternal() at Patched_Sandbox.Engine.Platform.GameRunSingleFrame_0(Object ) at Sandbox.Engine.Platform.FixedLoop.<>c__DisplayClass11_0.<Run>b__0() at Sandbox.Engine.Platform.GenericLoop.Run(VoidAction tickCallback) at Sandbox.Engine.Platform.Game.RunLoop() at Sandbox.MySandboxGame.Run(Boolean customRenderLoop, Action disposeSplashScreen) at Torch.VRageGame.DoStart() in C:\jenkins\workspace\Torch_Torch_master\Torch\ViewModels\ViewModel.cs:line 62 at Torch.VRageGame.Run() 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()
Darkmist  [developer] 23 Sep, 2019 @ 10:35am 
There is definitely something going on there. Either Keen did some improvements or it's just that paralell execution is more likely on dedicated servers. I'll try to take a look at it when I have time.
Digi 23 Sep, 2019 @ 12:09pm 
That looks more like something else (maybe another mod) modifies the block list in a thread, because the code in that stacktrace looks to be running on the main thread so it's unlikely to be this mods' fault... unless this mod does add/remove blocks in a thread :P

If you still have that world that causes the constant crashing on restart, you should upload it.
Last edited by Digi; 23 Sep, 2019 @ 12:11pm
< >
Showing 1-15 of 17 comments
Per page: 1530 50