Facepunch / sbox-issues

176 stars 12 forks source link

Hotloading sometimes causes CSS to unload #3747

Open CarsonKompon opened 1 year ago

CarsonKompon commented 1 year ago

Describe the bug

I have noticed this problem for about a month now, but it's grown from happening 5-10% of the time to happening nearly every single time I hotload (likely happens more frequently as my project grows in size)

In this video I hotload 3 different times. The first time is a simple razor change to add a new UI element, which causes the CSS to unload completely forcing me to restart my gamemode to see my changes. The second time is a similar change where I remove the newly added element, which causes the game to hotload without issue. The third time is a change to the Player class that simply adds a new variable. Even though this third change is completely unrelated to UI, the CSS still unloads completely.

https://github.com/sboxgame/issues/assets/5159369/0020ef36-b81b-4024-97a2-c50393f2a08e

To Reproduce

Make a code change to cause a hotload. After the hotload is complete, your CSS may or may not unload completely (as seen in the video)

Expected behavior

The CSS should stay loaded upon a hotload and RAM usage should not grow as it does in the video.

Media/Files

No response

Additional context

No response

CarsonKompon commented 11 months ago

Haven't experienced this once since scene.

PolSpock commented 11 months ago

lol i just got it now with the scene

CarsonKompon commented 11 months ago

lol i just got it now with the scene

Could you take a video of you being able to replicate it in scene? If so I'll re-open (or just make a new issue with that video)

PolSpock commented 11 months ago

After setting a dynamic value in a razor component, like <ScrollingNumber NewNumber=@(GameManager.ActiveScene.Components.GetAll<MonkeyPlayer>().Where(x => x.Network.IsOwner).FirstOrDefault().Money) /> you will get the issue with the below error

Is an ugly way to assign attributes in a component, but there is no reason to get a full stylesheet crash

Fast hotload attempted, but members have changed.

   at Sandbox.ILHotload.Replace(Assembly baseAssembly, Assembly oldIlHotloadAssembly, Assembly newIlHotloadAssembly)
   at Sandbox.PackageLoader.TryFastHotload(LoadedAssembly incoming, LoadedAssembly outgoing)
   at Sandbox.PackageLoader.AddAssembly(LoadedAssembly incoming)
   at Sandbox.PackageLoader.AddAssembly(Package package, String assemblyName, TrustedBinaryStream dllStream)
   at Sandbox.PackageLoader.LoadAssemblyFromPackage(ActivePackage ap, String filename)
   at Sandbox.PackageLoader.LoadPendingChanges()
   at Sandbox.PackageLoader.Tick()
   at Sandbox.GameMenu.GameMenuDll.FinishLoadingAssemblies()
   at Sandbox.GameMenu.GameMenuDll.Tick()
   at Sandbox.EngineLoop.FrameStart()
   at Sandbox.EngineLoop.RunFrame(CMaterialSystem2AppSystemDict appDict, Boolean& wantsQuit)
   at Sandbox.SourceEngineApp.RunFrame() in C:\build\_work\sbox\sbox\engine\Launcher\SourceEngineApp.cs:line 48
   at Sandbox.SourceEngineApp.RunLoop() in C:\build\_work\sbox\sbox\engine\Launcher\SourceEngineApp.cs:line 39
   at Sandbox.Program.LaunchGame() in C:\build\_work\sbox\sbox\engine\Launcher\Launcher.cs:line 93
   at Sandbox.Program.Main() in C:\build\_work\sbox\sbox\engine\Launcher\Launcher.cs:line 58

https://github.com/sboxgame/issues/assets/5229571/8b007c41-05f2-479d-8cac-c5bd9f73104b