DeepFreeze Continued...

DeepFreeze Continued...

38.2k Downloads

Error spam and UI becomes unusable in Tracking Station

MrKiel opened this issue · 7 comments

commented

I've been experiencing a bug entering the tracking station while using this mod. It renders the tracking station UI unusable and requires ending the game via alt-f4 or task manager, and I didn't have a chance to look into it until today. Please see the screenshot of the debug screen spamming errors when this problem occurs:

http://images.akamai.steamusercontent.com/ugc/499143085899298410/F70070FFEE84DCF901E389C71937CF48D339FAA2/

A sample of the output log upon entering the tracking station:

DF.DFIntMemory[FFDCF83C][1738.91]: Err: System.NullReferenceException: Object reference not set to an instance of an object   at DF.DFIntMemory.CheckVslUpdate () [0x00000] in <filename unknown>:0    at DF.DFIntMemory.FixedUpdate () [0x00000] in <filename unknown>:0 

(Filename: C:/buildslave/unity/build/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 56)

DF.DFGameSettings[A0F02900][1738.93]: Dump of KnownVessels

(Filename: C:/buildslave/unity/build/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 56)

DF.DFGameSettings[A0F02900][1738.93]: Vessel = f5ea1f18-0c20-466e-a2d8-716e113fc6c5 Name = Evella I crew = 0 frozencrew = 3

(Filename: C:/buildslave/unity/build/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 56)

DF.DFIntMemory[FFDCF83C][1738.93]: FixedUpdate failed to update DeepFreeze Internal Vessel Memory

(Filename: C:/buildslave/unity/build/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 56)

commented

I'm a little rusty, but I've compared the output log with the code, this is what I've found so far.

There's an exception caught in DFIntMemory.cs at line 694, evidenced by the log containing a repeated dump of known vessels. Once this information is dumped, the vessel is not null (line 717) or loaded (line 724) so the method returns. On next fixedupdate the same thing happens again.

This would imply that under certain conditions, something is causing line 692 to throw an exception:
vessel = allVessels.Find(v => v.id == vesselId);

But, you can probably rule out the allVessels list as that's used successfully to dump vessel information immediately afterwards. I'm not familiar enough with the code to give you more I'm afraid!

I haven't had any success trying to get this to happen again, it looks like I'll just have to let it happen naturally and see if there's any more information when it does!

commented

Yes you have correctly analysed the error. This has happened before hence the try / catch statement trying to track it down.
The Dump of known vessels is dumping from a DeepFreeze dictionary. Which contains one entry for your vessel that has 3 frozen crew on-board.
What's interesting next is that this piece of code:
if (allVessels.Count == 0 || allVessels == null) { this.Log("FlightGlobals.Vessels = 0 or null"); } else { foreach(Vessel vsl in allVessels) { this.Log("Vessel " + vsl.id + " name = " + vsl.name); } }

Which fails to issue any message at all and in fact we then get the nullref exception and we never see the output of this line:
this.Log("Exception: " + ex);

This tells me that in fact allVessels is NULL. because I stupidly should have checked for NULL First before checking allVessels.Count - Which is actually causing a SECOND null reference exception.

Now why is allVessels NULL. Because it should never be.... it's actually reference to FlightGlobals.Vessels, which should never be NULL when this code executes.

I think this is the real kicker here in your log file we get a NullRef on the PSystemSetup (where the planet bodies etc are stored by KSP) and then we get an error trying to do something with an asteroid, these are stock code errors.
`
NullReferenceException: Object reference not set to an instance of an object
at FloatingOrigin.setOffset (Vector3d refPos) [0x00000] in :0
at FloatingOrigin.SetOffset (Vector3d refPos) [0x00000] in :0
at PSystemSetup.SetSpaceCentre () [0x00000] in :0
at PSystemSetup.OnLevelWasLoaded (Int32 level) [0x00000] in :0
(Filename: Line: -1)

NullReferenceException: Object reference not set to an instance of an object
at ScenarioDiscoverableObjects.m__31A (.Vessel v) [0x00000] in :0
at System.Linq.Enumerable.Count[Vessel](IEnumerable1 source, System.Func2 selector) [0x00000] in :0
at ScenarioDiscoverableObjects.UpdateAsteroids (Double UT) [0x00000] in :0
at ScenarioDiscoverableObjects+��.MoveNext () [0x00000] in :0 UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
ScenarioDiscoverableObjects:Start()
`

I think something else is going on in your install that is causing KSP to fail and the PSystem is not initializing on switch to the TrackingStation scene. Evidenced that it then couldn't UpdateAsteroids.. Asteroids are in fact just vessels and appear in the same FlightGlobals.Vessels list.
After that DeepFreeze has the same problem trying to see the vessels in-game.

How do we fix this? I don't think we can. We need to figure out why the FlightGlobals.Vessels list is empty. But that's a KSP bug or perhaps another mod causing an issue.
I have made a tweak to my code to handle this better and not spam the log it will only do it 5 times and check for the null list before checking the count.
Looking at the mods you have installed nothing is standing out at me. It's a mystery, and I'd hazard a guess perhaps a stock bug... but unless it can be re-produced without a mod installed it is not considered a stock bug.

commented

I'm inclined to agree - I'm using Asteroid Day, which should be pretty safe but I'm not going to rule it out as a source of problems. It could simply be that this is a stock but that is particularly tricky to catch red-handed.

Try as I might I cannot force this error to reproduce again. In total, it's happened maybe 4 times in 40-odd hours of recent gameplay.

Thanks for your assistance in ruling this mod out as a source and pointing me in the right direction. If it happens again I may simply start a new career to rule out the save file as a possibly cause.

commented

Some changes to handle this better in V0.20.4.0

commented

Wonder if this is still a problem in version 1.1

commented

I'm going to close this as I have done just about all I can about this error.
Deepfreeze now checks for when FlightGlobals.Vessels is NULL (which should NEVER occur).
And issues up to 5 ERROR messages and then stops.