KSP Recall

KSP Recall

345k Downloads

KSP 1.12.5 (or a 3rd party add'on?) are not honouring the `once` attribute from the `KSPAddon` decoration

Lisias opened this issue · 3 comments

commented

As the title says!!

A code of mine using [KSPAddon(KSPAddon.Startup.MainMenu, true)] is being instantiated every time the Main Menu is called!!

Evidence: Player.log

After entering a savegame (you need to open the VAB or KSP on each one) and quitting to the Main Menu 3 times, I got:

> cat Player.log | grep "Instantiating addon 'TweakScaleHotKeys' from assembly 'Scale'" | wc -l
3

I just can't say how many add'ons are being ROYALLY screwed up by this crap!!!!

TODO: Check if previous KSP releases also suffers from this problem!

commented

Well, that's the whole history:

An user asked for help on Forum about a weird issue. While digging on their logs, I found:

NullReferenceException: Object reference not set to an instance of an object
  at TweakScale.Features.ScaleChaining.DeInit () [0x00012] in <d64755e43d324177804233d3acaee766>:0
  at TweakScale.TweakScaleHotKeys.OnDestroy () [0x00005] in <d64755e43d324177804233d3acaee766>:0

What should not be happening, unless the TweakScaleHotKeys would be being instantiated twice (or more), because the current Instance is being kept on a static variable, the damned thing is using [KSPAddon(KSPAddon.Startup.MainMenu, true)] (note the true on the once parameter), and it's using DontDestroyOnLoad.

And since I also found

> cat Player.log | grep "Instantiating addon 'TweakScaleHotKeys' from assembly 'Scale'" | wc -l
2

on that log, I concluded I had evidence of KSP instancing things multiple times.

BUT on KSP 1.4.3 I also had the log "spam", but not the NRE. And checking again the KSP 1.12.5 log, I also found the spam but again not the NRE.

So the log "spam" is a bug by itself. It only happend that between the thousands of false alarms, one of them ended up hitting something real.

commented

Well, I just checked again 1.12.5 to see if I had missed something. I quit KSP from inside Editor this time, just to see if something changes.

Same thing.

There's a log spam about Instantiating addon 'TweakScaleHotKeys' from assembly 'Scale' every time I reach the Main Menu, but there's no NRE when KSP quits.

So, and again, it's something on the user's rig. The user is using an Intel asymmetric/"hybrid" CPU (4 P-Cores and 8 E-Cores), so perhaps this is a factor? Unity (and so KSP) handles concurrently pretty stupidly, and I already had stumbled this kind of crap before.

commented

Humm… Weird. I found the same 3 log entries on KSP 1.4.3. However, I'm not finding the NRE that should happen at the end of the log…

Player.log