Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException: Object reference not set to an instance of an object | connector port bug? #167

Closed
LouisCyfer opened this issue Jul 19, 2016 · 14 comments

Comments

@LouisCyfer
Copy link

LouisCyfer commented Jul 19, 2016

hi, this is what my log spits out .. it seems to crash my game (at least thats the last exception in my logs
exception.txt

226.1066: NullReferenceException: Object reference not set to an instance of an object at KIS.ModuleKISInventory.GuiHandleUsedSlot (Rect textureRect, Int32 slotIndex) at KIS.ModuleKISInventory.GuiInventory () at KIS.ModuleKISInventory.GuiMain (Int32 windowID) at UnityEngine.GUILayout+LayoutedWindow.DoWindow (Int32 windowID) at UnityEngine.GUI.CallWindowDelegate (UnityEngine.WindowFunction func, Int32 id, UnityEngine.GUISkin _skin, Int32 forceRect, Single width, Single height, UnityEngine.GUIStyle style)

@ihsoft
Copy link
Owner

ihsoft commented Jul 19, 2016

Please, attach full logs and provide steps to reproduce.

@LouisCyfer
Copy link
Author

LouisCyfer commented Jul 19, 2016

this exception vanished/didnt happened again after i removed the magnet off my orbital station, im sorry i cannot provide a log anymore, this happened 2 times, then i tried to remove things off the station where it happened.

sry for not beeing much helpful, but im trying to help tho
EDIT: the magnets were attached onto a CC-R2 Connector Port

EDIT 2:
unsure if thats connected to this one, but this time i can provide a log (see attachment)
KSP.log.txt

[ERR 14:00:59.194] Input is null
at System.Environment.get_StackTrace()
at ConfigNode.CleanupInput(System.String value)
at ConfigNode.AddValue(System.String name, System.String value)
at BaseFieldList.Save(.ConfigNode node)
at PartModule.Save(.ConfigNode node)
at ProtoPartModuleSnapshot..ctor(.PartModule module)
at ProtoPartSnapshot..ctor(.Part PartRef, .ProtoVessel protoVessel)
at ProtoVessel..ctor(.Vessel VesselRef)
at Vessel.Initialize(Boolean fromShipAssembly)
at Part.decouple(Single breakForce)
at KIS.KIS_Shared.DecoupleAssembly(.Part assemblyRoot)
at KIS.KISAddonPickup.MoveAttach(.Part tgtPart, Vector3 pos, Quaternion rot, System.String srcAttachNodeID, .AttachNode tgtAttachNode)
at KIS.KISAddonPickup.OnPointerAction(PointerTarget pointerTarget, Vector3 pos, Quaternion rot, .Part tgtPart, System.String srcAttachNodeID, .AttachNode tgtAttachNode)
at KIS.KISAddonPointer.UpdatePointer()
at KIS.KISAddonPointer.Update()

EDIT 3: the connector ports are not stackable anymore .. unsure what caused it, or if it will fix it itself
connector port stack bug

EDIT 4: strike out EDIT 3, that is/was caused by another mod named KRnD
.. just FYI .. im trying to help by reporting what im observating, im not complaining or trying to

i cannot imagine any KSP without KIS/KAS!

@LouisCyfer LouisCyfer changed the title NullReferenceException: Object reference not set to an instance of an object NullReferenceException: Object reference not set to an instance of an object | connector port bug? Jul 21, 2016
@Starwaster
Copy link

KIS shouldn't be trying to snapshot anything from its constructor. You should wait until Start() / OnStart() to run that kind of code. Otherwise you're not allowing time for initialization methods on other MonoBehavior objects to execute. Including other mod's PartModules. It's no wonder you've got compatibility issues with other mods. (for which blame is wrongly being assigned to every other mod with which KIS is incompatible)

Define either Start/OnStart method and do your snapshotting there. (as well as any other KIS initialization which might depend on other mods having initialized on the part)

@ihsoft
Copy link
Owner

ihsoft commented Jul 29, 2016

What code exactly you're talking about? The stack trace above clearly shows that snapshot was attempted by the KSP core (Part.decouple()).

@Starwaster
Copy link

Yes you're right. I had just come here from looking at your code for KIS_Item and I was preoccupied with what I found there and I didn't pay enough attention to what was presented in this issue, so what I said isn't valid to this instance, sorry.

But what I said is still valid for the cases where you're trying to snapshot before any Unity or Mono methods have been called and you should give serious thought to moving that code to where it's getting called after other PartModule's classes have had chance to initialize.

@LouisCyfer
Copy link
Author

im happy about hearing you guys talking about this bunch of issue bundle (?) .. im sorry when it does not clearly conform to other issue-reports but i just try to give you guys something so you can work with that to improve the mod/add-on

regards :)

@ihsoft
Copy link
Owner

ihsoft commented Jul 29, 2016

But what I said is still valid for the cases where you're trying to snapshot before any Unity or Mono methods have been called and you should give serious thought to moving that code to where it's getting called after other PartModule's classes have had chance to initialize.

The whole approach with part snapshots has proven to be error prone. E.g. this bug demonstrates an issue with a part that was properly created and initalized. Alas, it's not possible to get rid of it without major refactoring of KIS. I plan to do it but it's a long term effort. For now the only feasible approach is making patches for the spotted problems (e.g. this one once I'm able to reproduce it).

@ihsoft
Copy link
Owner

ihsoft commented Jul 29, 2016

@LouisCyfer Hey, are you able to reliably reproduce the issue? Can you try removing all the non-part mods (i.e. mods that modify behavior of the existing parts) and check if the error still exists? As far as I can tell from the logs there is a mod that adds a badly initialized module to a part. Snapshot methods cannot handle nulls in the config/persistent fields, and this module seems to have a null there.

@LouisCyfer
Copy link
Author

LouisCyfer commented Jul 29, 2016

i can try that, reporting back once ive done .. going to assume its KRnD (if not one of the other parts) .. cuz when i uninstalled that one it reverted and the parts worked as intended .. i'll update soon!

EDIT:
once i only installed KRnD 1.8 it happened again (first screenshot --> watch the inventory of both Kerb's .. you might guess where the items intended to belong to/they're not correctly in the Kerbs inventory at least)
krnd_issue1
KSP.log_withKRnD.txt

right after i uninstalled KRnD 1.8 (basicly deleted the folder in /GameData) i had alittle bit of resort the inventory but everything seemed fine again
krnd_issue3
KSP.log_withoutKRnD.txt

hope this helps tho .. just for the record, im not trying to disregard or blame any mods or stuff .. im fan of every creative work that is been done to KSP at all, its a massive efford, time consumption and lots of unpaid work tho.

@ihsoft
Copy link
Owner

ihsoft commented Jul 30, 2016

just for the record, im not trying to disregard or blame any mods or stuff .. im fan of every creative work that is been done to KSP at all, its a massive efford, time consumption and lots of unpaid work tho.

I'm not taking it as a blame :) And I'm really appreciated you've spend your time to gather all these details. Now I'm confident it's KRnD that makes the problem. I'll take a look if it can be worked around.

@ihsoft
Copy link
Owner

ihsoft commented Jul 30, 2016

TBD: Before decoupling parts do a prefabs clean up. It looks like some mods update prefabs after the KIS config stage (which normally does the cleanup).

@LouisCyfer
Copy link
Author

im glad i could be any helpful, and yes i know KRnD is officially supported for KSP 1.1.2 but it should still work

im looking forward for the next update! tyvm!

@ihsoft
Copy link
Owner

ihsoft commented Feb 16, 2017

@LouisCyfer Is this bug still happening in 1.2?

@LouisCyfer
Copy link
Author

hiyas, I assume you mean KSP 1.2+ and no I did not see this occouring anymore, this one seems solved and I'm closing this.

Ty for your updates :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants