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

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

Open
Lisias opened this issue Jul 28, 2023 · 3 comments
Assignees
Labels
bug Something isn't working Not My Fault Not my Fault! I'm innocent! :)

Comments

@Lisias
Copy link
Contributor

Lisias commented Jul 28, 2023

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!

@Lisias Lisias self-assigned this Jul 28, 2023
@Lisias Lisias added bug Something isn't working Not My Fault Not my Fault! I'm innocent! :) labels Jul 28, 2023
@Lisias
Copy link
Contributor Author

Lisias commented Jul 28, 2023

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

@net-lisias-ksp net-lisias-ksp locked as too heated and limited conversation to collaborators Jul 28, 2023
@Lisias
Copy link
Contributor Author

Lisias commented Jul 28, 2023

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.

@Lisias Lisias changed the title KSP 1.12.5 (others?) are not honouring the once attribute from the KSPAddon decoration KSP 1.12.5 (or a 3rd party add'on?) are not honouring the once attribute from the KSPAddon decoration Jul 28, 2023
@Lisias
Copy link
Contributor Author

Lisias commented Jul 28, 2023

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working Not My Fault Not my Fault! I'm innocent! :)
Projects
None yet
Development

No branches or pull requests

1 participant