pellinor0 / TweakScale

Forked from Gaius Goodspeed's Goodspeed Aerospace Part & TweakScale plugin
29 stars 23 forks source link

Exception on writeDryCost: System.NullReferenceException: Object reference not set to an instance of an object #81

Closed 7ranceaddic7 closed 3 years ago

7ranceaddic7 commented 5 years ago

So, I'm getting a log full of these ...

[LOG 20:10:12.122] TweakScale::PrefabDryCostWriter: Start [ERR 20:10:12.123] [TweakScale] Exception on writeDryCost: System.NullReferenceException: Object reference not set to an instance of an object at PartModuleList.Contains (Int32 classID) [0x00000] in :0 at PartModuleList.Contains (System.String className) [0x00000] in :0 at TweakScale.PrefabDryCostWriter.WriteDryCost () [0x00000] in :0

[LOG 20:10:12.123] [TweakScale] part=kerbalEVA () [ERR 20:10:12.123] [TweakScale] Exception on writeDryCost: System.NullReferenceException: Object reference not set to an instance of an object at PartModuleList.Contains (Int32 classID) [0x00000] in :0 at PartModuleList.Contains (System.String className) [0x00000] in :0 at TweakScale.PrefabDryCostWriter.WriteDryCost () [0x00000] in :0

[LOG 20:10:12.123] [TweakScale] part=kerbalEVAfemale () [ERR 20:10:12.123] [TweakScale] Exception on writeDryCost: System.NullReferenceException: Object reference not set to an instance of an object at PartModuleList.Contains (Int32 classID) [0x00000] in :0 at PartModuleList.Contains (System.String className) [0x00000] in :0 at TweakScale.PrefabDryCostWriter.WriteDryCost () [0x00000] in :0

... almost 1400 repetitions.

Lisias commented 5 years ago

@7ranceaddic7 , could you please make a test?

Create a new savegame with exactly the same mods you have now. Create a new vessel, tweakscake something, and fly it. See if this exception happens.

Then copy a vessel from the old savegame that you are sure suffered from the problem. Try again, see what happens.

I had this exact Exception once, but then it vanished - and I don't have any savegame around where this happens now, so I'm high and dry on this. =/ (I'm trying to solve it myself)

7ranceaddic7 commented 5 years ago

This is happening in EVERY game launch; so, it's not a transient for me. Then, I'm also running 200+ mods. Here is the .ckan file of my mods for you to review. KSP.ckan.txt

7ranceaddic7 commented 5 years ago

So, created a test install (KSP_test) and these are the ONLY exceptions present...

[LOG 19:17:51.890] TweakScale::PrefabDryCostWriter: Start [ERR 19:17:51.891] [TweakScale] Exception on writeDryCost: System.NullReferenceException: Object reference not set to an instance of an object at PartModuleList.Contains (Int32 classID) [0x00000] in :0 at PartModuleList.Contains (System.String className) [0x00000] in :0 at TweakScale.PrefabDryCostWriter.WriteDryCost () [0x00000] in :0

[LOG 19:17:51.891] [TweakScale] part=kerbalEVA () [ERR 19:17:51.891] [TweakScale] Exception on writeDryCost: System.NullReferenceException: Object reference not set to an instance of an object at PartModuleList.Contains (Int32 classID) [0x00000] in :0 at PartModuleList.Contains (System.String className) [0x00000] in :0 at TweakScale.PrefabDryCostWriter.WriteDryCost () [0x00000] in :0

[LOG 19:17:51.891] [TweakScale] part=kerbalEVAfemale ()

Here is the ckan install file: KSP_test.ckan.txt

Lisias commented 5 years ago

Assuming no one fix it sooner :) I will be on it on the WeekEnd.

I'm somewhat worried on asking for your KSP.log, as mine got ghastly huge when this happens! But keep one zipped somewhere, just in case. :)

7ranceaddic7 commented 5 years ago

By ghastly, you'd be referring to an 84.5MB file BEFORE launching into a savefile?

Yeah, it's zip is available here ... (fortunately the compress quite well.)

https://drive.google.com/open?id=0B7arxv3DfQDld29ZVHBYOVdCV2c

pellinor0 commented 5 years ago

[LOG 19:17:51.891] [TweakScale] part=kerbalEVA () [LOG 19:17:51.891] [TweakScale] part=kerbalEVAfemale ()

These ones look a bit suspicious. For those parts the exception should be harmless because there is no way to rescale them. But why is there a TweakScale module on the kerbal EVA models? This is probably the result of a blanket MM patch putting TweakScale on everything. Did you add that or does it come from a mod?

From a quick look at the logfile, the exception seems to happen for every part, and there are quite a lot of exceptions earlier in the log. So my guess is that either those exceptions already broke something, or your install adds something to every part that makes TweakScale stumble.

7ranceaddic7 commented 5 years ago

Yeah, that's what I thought when I saw those two. Somewhere there is a @PART[*] TweakScale config, but I'm at a loss as to where it is.

To that end, I've begun a test install to track it down by stepping through by copying folders over and running KSP.

You might want to take a look at #82 as well.

Lisias commented 5 years ago

Well… I have some info about where not to find the problem.

I running a search on every CFG on my current installment (where this error happens), and this is what I got until the moment:

This doesn't dismiss the @pellinor0 hypothesis - a mod dully adding TweakScale to a kerbalEVA - only eliminates the easy pickings. One could had messed up while searching for parts using a resource...

Lisias commented 5 years ago

In time, found more parts suffering from the problem.

[ERR 23:32:05.473] TweakScale::PrefabDryCostWriter: negative dryCost: part=M3X.hypersonicnosecone, DryCost=-830.0001

[ERR 23:32:05.477] TweakScale::PrefabDryCostWriter: negative dryCost: part=DiamagneticAntimatterTrap, DryCost=-1.3244E+09

Until the moment, every single part that blew a writeDryCost exception (save the kerbalEVA* ones) uses (directly or injected by Module Manager) uses InterstellarFuelSwitch or ModuleB9PartSwitch .

Well, no news. But at least we have confirmation.

pellinor0 commented 5 years ago

Forget the part about the PART[*] config, I was wrong about that. The query if that part has a TweakScale module is what throws the exception (the "ModulePartList.Contains" part). So something is messed up with that list. Either because KSP itself has a problem or because some mod broke it.

Lisias commented 5 years ago

This issue is, in true, TWO different issues that happened to occur on the same code.

The kerbalEVA* ones are still WiP, but the NRE are solved on the 2.4.0.4 Pre-Release:

https://github.com/net-lisias-ksp/TweakScale/releases/tag/PRERELEASE%2F2.4.0.4

Lisias commented 5 years ago

The kebalEVA* issues are an unholy interaction with some other mod. I just don't reproduce it here on my test bed, what means that I will have to "import" mods from my RPG installment one by one until find the culprit.

And even then… As this can happens due a unholy interaction between two other parts, and TweakScale would be just a bystander victim.

7ranceaddic7 commented 5 years ago

I know that Kerbal Inventory System mucks with kerbalEVA and the commadPod seats. You might want to start there.

Lisias commented 5 years ago

Nice hint. Unfortunately, KIS intervention is only this:

@PART[kerbalEVA*]
{
        MODULE
        {
                name = ModuleKISInventory
        }
        MODULE
        {
                name = ModuleKISPickup
        }
}

So, if KIS had, in fact, stumbled on my feet, the stumbling gun is on the C# Source Code. I will give it a try later, however. This Exception appears to be harmless, and it's something I can mask programmatically (a hell of a shunt, but…) on TweakScale's code.

7ranceaddic7 commented 5 years ago

Here's my current "healthy" kerbalEVA.

https://docs.google.com/document/d/1r_UdnvAl9QlhPfFJDno4htrx4E3Pg-MRz7uegtfePx8/edit?usp=sharing