SSTU - Shadow Space Technologies Unlimited

SSTU - Shadow Space Technologies Unlimited

98.5k Downloads

SSTU/Ferram conflict, KSP 1.30

vossiewulf opened this issue · 4 comments

commented

Seeing these in logs where I am crashing entering or leaving the VAB.

`NullReferenceException: Object reference not set to an instance of an object
at FerramAerospaceResearch.FARPartGeometry.GeometryPartModule.RebuildAllMeshData () [0x00000] in :0
at FerramAerospaceResearch.FARPartGeometry.GeometryPartModule.GeometryPartModuleRebuildMeshData () [0x00000] in :0
UnityEngine.Component:SendMessage(String, Object, SendMessageOptions)
UnityEngine.Component:SendMessage(String)
SSTUTools.SSTUModInterop:onPartGeometryUpdate(Part, Boolean)
SSTUTools.SSTUModularFuelTank:updateModels()
SSTUTools.SSTUModularFuelTank:initialize()
SSTUTools.SSTUModularFuelTank:OnLoad(ConfigNode)
PartModule:Load(ConfigNode)
Part:LoadModule(ConfigNode, Int32&)
ShipConstruct:LoadShip(ConfigNode)
ShipConstruction:LoadShip(String)
FlightDriver:Start()

(Filename: Line: -1)`

commented
commented

The problem comes down to Unity not deleting objects when told to delete them -- it waits until the next frame. Sadly if anything comes along and tries to reference those objects prior to them actually being deleted... it causes things to explode (the real solution is for Unity actually delete things when told to).

Have added in a delay to the FAR update callback to make sure the part is initialized and Unity has deleted any meshes/objects marked for deletion. This should give FAR a 'clean'

(using the same delay that is used for drag-cube updates; meaning the FAR rebuild will be done in the first FixedUpdate after the geometry is updated).

Sadly I have no ability to test this fix (I don't use FAR), and it will only be available for 1.3.1 (the last release was the last 1.3.0 release). Should be available with the next release (likely this weekend).

commented

DestroyImmediate() does what it says on the tin, but there can be side effects depending on precisely -when- it is called. It can cause problems when called from event-handlers and on the UI thread (or anywhere but the main thread). Hard to track down, mind bendingly strange and inconsistent problems.

It could be a potential solution, but in this case I've simply delayed the far-geometry updates until the next FixedUpdate. As a bonus each part will only call the voxel update at most once per frame now, rather than potentially many times from editor-modified events. Seems to be working so far, no null-ref spamming in the editor or flight scenes in simple tests, and FAR appears to be voxelizing things appropriately (according to the log).

commented

The problem comes down to Unity not deleting objects when told to delete them -- it waits until the next frame

Is this true even when using DestroyImmediate (as opposed to Destroy)?