Small Harmony patch that silences a recurring NullReferenceException loop in the Through-The-Eyes mod (a.k.a. ThroughTheEyes / FirstPerson).
FirstPerson.FirstPersonEVA.Update() runs every frame. Whenever the
active vessel changes, it calls EVABoundFix.Hook(eva), which constructs
a new EVABoundFix(eva) instance. The constructor touches several KFSM
fields directly:
myeva.On_bound_fall.OnCheckCondition = ...
myeva.On_bound_land.OnCheckCondition = ...
for (int i = 0; i < myeva.st_bound_fl.StateEvents.Count; ++i) ...For some custom EVA suits or specific game states one of these fields is
still null, so the constructor throws a NullReferenceException. Because
Update() keeps calling Hook on every frame, the exception is logged
hundreds of times per second. In long sessions this floods KSP.log
(seen growing to 200+ MB) and contributes to Mono GC mark-stack overflow
crashes.
Sample stack from KSP.log:
NullReferenceException: Object reference not set to an instance of an object
FirstPerson.EVABoundFix..ctor (KerbalEVA eva)
FirstPerson.EVABoundFix.Hook (KerbalEVA eva)
FirstPerson.FirstPersonEVA.Update ()
A Harmony Prefix on FirstPerson.EVABoundFix.Hook reflects into the
KerbalEVA and checks the fields the constructor will dereference
(On_bound_fall, On_bound_land, st_bound_fl, plus eva and
eva.vessel). If any required field is null, Hook is skipped and a
single deduplicated log line is emitted per condition.
Trade-off: when the prefix skips, first-person EVA bindings won't be installed for that particular Kerbal until something refreshes the FSM. In practice the next vessel switch or scene reload picks up a valid state. No NRE, no log spam.
Requires the .NET SDK with net472 targeting.
dotnet build --configuration Release
Output: bin/Release/TTE_Fix.dll. Drop into a new folder:
<KSP>/GameData/TTE_Fix/TTE_Fix.dll
Clear <KSP>/GameData/ModuleManager.ConfigCache so patches are
recomputed on next launch.
The KSP log should contain:
[TTE_Fix] patched EVABoundFix.Hook
If the skip path triggers, you'll see at most one of these lines per distinct cause:
[TTE_Fix] skipped Hook: st_bound_fl is null
- KSP 1.12.5
- Through-The-Eyes 2.0.4.x
- Harmony 2.x
GPL-3.0, matching the upstream Through-The-Eyes license.
This repo does not redistribute any Through-The-Eyes code; the patch resolves types via reflection at runtime. Upstream: https://github.com/linuxgurugamer/Through-The-Eyes