Skip to content

initERacksActive throws NRE on OnStart when IVA placeholder mode is active (KSP Community Fixes) #54

Description

@liltine

Environment:

OMS/NEOS 0.10.0
KSP 1.12.5
KSP Community Fixes installed, with IVA handling set to "placeholder" mode

Summary:

With KSPCF's IVA placeholder mode enabled, both MPL_Module and MSL_Module throw a NullReferenceException in initERacksActive() during OnStart. Because the exception aborts OnStart, the labs never finish initializing and the equipment install action is never registered — equipment carriers dock/sit on the same vessel with correct equipment, but no install option ever appears on the lab or carrier.
Root cause:

initERacksActive() guards only on part.internalModel != null. In placeholder IVA mode the internal model object exists (non-null) but lacks the expected mesh hierarchy, so:

csharpGameObject labIVA = part.internalModel.gameObject.transform.GetChild(0).GetChild(0).gameObject;
if (labIVA.GetComponent<MeshFilter>().name == "Lab1IVA")  // GetComponent returns null → .name throws
GetComponent<MeshFilter>() returns null and .name throws.

Stack trace:

[EXC 17:07:51.072] NullReferenceException: Object reference not set to an instance of an object
	NE_Science.MPL_Module.initERacksActive () (at <a6ea64e79c044aaca2123ac101d1d50c>:0)
	NE_Science.MPL_Module.updateLabStatus () (at <a6ea64e79c044aaca2123ac101d1d50c>:0)
	NE_Science.Lab.updateStatus () (at <a6ea64e79c044aaca2123ac101d1d50c>:0)
	NE_Science.Lab+<updateState>d__30.MoveNext () (at <a6ea64e79c044aaca2123ac101d1d50c>:0)
	UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <12e76cd50cc64cf19e759e981cb725af>:0)
	UnityEngine.DebugLogHandler:LogException(Exception, Object)
	ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
	UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
	NE_Science.Lab:OnStart(StartState)
	NE_Science.MPL_Module:OnStart(StartState)
	Part:ModulesOnStart()
	<Start>d__323:Part+<Start>d__323.MoveNext_Patch0(<Start>d__323)
	UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
[ERR 17:07:51.073] Module MPL_Module threw during OnStart: System.NullReferenceException: Object reference not set to an instance of an object
  at NE_Science.MPL_Module.initERacksActive () [0x00043] in <a6ea64e79c044aaca2123ac101d1d50c>:0 
  at NE_Science.MPL_Module.OnStart (PartModule+StartState state) [0x0000c] in <a6ea64e79c044aaca2123ac101d1d50c>:0 
  at Part.ModulesOnStart () [0x00120] in <4b449f2841f84227adfaad3149c8fdba>:0 

[LOG 17:07:51.073] -INFO- Tac.LifeSupportModule[FFDB07E2][317.78]: OnStart: PreLaunch, Landed
[EXC 17:07:51.074] NullReferenceException: Object reference not set to an instance of an object
	NE_Science.MSL_Module.initERacksActive () (at <a6ea64e79c044aaca2123ac101d1d50c>:0)
	NE_Science.MSL_Module.updateLabStatus () (at <a6ea64e79c044aaca2123ac101d1d50c>:0)
	NE_Science.Lab.updateStatus () (at <a6ea64e79c044aaca2123ac101d1d50c>:0)
	NE_Science.Lab+<updateState>d__30.MoveNext () (at <a6ea64e79c044aaca2123ac101d1d50c>:0)
	UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <12e76cd50cc64cf19e759e981cb725af>:0)
	UnityEngine.DebugLogHandler:LogException(Exception, Object)
	ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
	UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
	NE_Science.Lab:OnStart(StartState)
	NE_Science.MSL_Module:OnStart(StartState)
	Part:ModulesOnStart()
	<Start>d__323:Part+<Start>d__323.MoveNext_Patch0(<Start>d__323)
	UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
[ERR 17:07:51.074] Module MSL_Module threw during OnStart: System.NullReferenceException: Object reference not set to an instance of an object
  at NE_Science.MSL_Module.initERacksActive () [0x00043] in <a6ea64e79c044aaca2123ac101d1d50c>:0 
  at NE_Science.MSL_Module.OnStart (PartModule+StartState state) [0x0000c] in <a6ea64e79c044aaca2123ac101d1d50c>:0 
  at Part.ModulesOnStart () [0x00120] in <4b449f2841f84227adfaad3149c8fdba>:0 

[LOG 17:07:51.075] -INFO- Tac.LifeSupportModule[FFDB07C8][317.78]: OnStart: PreLaunch, Landed

Repro:

Install KSP Community Fixes, set IVA mode to placeholder.
Place an MPL-600 or MSL-1000 on the pad (crewed, with an equipment carrier on the same vessel).
Observe the NRE in KSP.log during flight load; no install action appears on the lab.

Workaround:

Re-enable full IVA loading (disable placeholder mode). Install action returns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions