LGhassen / Scatterer

Atmospheric scattering mod for KSP
Other
191 stars 51 forks source link

NRE Spam #173

Closed nan0bug00 closed 2 months ago

nan0bug00 commented 2 years ago

Issue tl;dr: NRE Spam related to deleted unity object (I guess the sun that was deleted to create the transparent barycenter in Beyond Home? I don't really know.)

image

so... "hey there's more of these"

https://github.com/LGhassen/Scatterer/blob/3124f0cbaa051d77bdfb548bcc2ee054f8b36411/scatterer/Effects/SunFlare/SunflareCameraHook.cs#L27

https://github.com/LGhassen/Scatterer/commit/3124f0cbaa051d77bdfb548bcc2ee054f8b36411

also I guess I'm supposed to ping @linuxgurugamer since he's the one that was working on it? 

LGhassen commented 2 years ago

Thanks for going through with this. I already replaced all these on the dev branch https://github.com/LGhassen/Scatterer/commit/50a2f8e7bd9cdd65aadbde5aa14daea44ca90fdd haven't merged/released yet because I didn't have enough time for testing

BrettRyland commented 2 years ago

I'm also getting a bunch of NRE spam in Ubuntu and getting white screens in a variety of places, such as the KSC overview. Looking at the dev branch code, the initial exceptions in my log that aren't already fixed are occuring due to

[EXC 22:02:27.699] UnityException: GetComponentFastPath is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'TemporalAntiAliasing' on game object 'Camera 00'.
See "Script Serialization" page in the Unity Manual for further details.
  UnityEngine.Component.GetComponent[T] () (at <2425394cf09642369e2109953e31f62b>:0)
  scatterer.TemporalAntiAliasing..ctor () (at <684aa87c0d2345f8a9e4739403f4afff>:0)
  UnityEngine.DebugLogHandler:LogException(Exception, Object)
  ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
  UnityEngine.GameObject:AddComponent()
  scatterer.Scatterer:Init()
  scatterer.<DelayedInit>d__35:MoveNext()
  UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

for Camera 00, Camera 01, Camera ScaledSpace and Camera ScaledSpace from (I think) this line TemporalAntiAliasing.cs#L42, which then leads to spamming

[EXC 22:02:27.932] NullReferenceException: Object reference not set to an instance of an object
  scatterer.TemporalAntiAliasing.OnPreCull () (at <684aa87c0d2345f8a9e4739403f4afff>:0)
  UnityEngine.DebugLogHandler:LogException(Exception, Object)
  ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
  UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)
[EXC 22:02:27.935] NullReferenceException: Object reference not set to an instance of an object
  scatterer.TemporalAntiAliasing.ResetProjection () (at <684aa87c0d2345f8a9e4739403f4afff>:0)
  scatterer.TemporalAntiAliasing.OnPostRender () (at <684aa87c0d2345f8a9e4739403f4afff>:0)
  UnityEngine.DebugLogHandler:LogException(Exception, Object)
  ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
  UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

to the KSP.log even when the screen isn't white.

I can try cloning and compiling Scatterer if you need stacktraces with line numbers.

BrettRyland commented 2 years ago

Well, I decided to go ahead and compile it from the dev branch anyway... After fixing the HintPath and capitalisation in the .csproj and .sln files and commenting out the post-build stuff (which is Windows specific), I got it to build fine, though there are a number of compiler warnings:

brett@br-workhorse:/storage/github/Scatterer/scatterer$ dotnet build --configuration Debug && cp bin/Debug/scatterer.* ~/Games/KSP/GameData/Scatterer/
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Nothing to do. None of the projects specified contain packages to restore.
/storage/github/Scatterer/scatterer/Effects/Proland/Ocean/OceanWhiteCaps.cs(11,20): warning CS0108: 'OceanWhiteCaps.name' hides inherited member 'Object.name'. Use the new keyword if hiding was intended. [/storage/github/Scatterer/scatterer/scatterer.csproj]
/storage/github/Scatterer/scatterer/Effects/Proland/Atmosphere/SkyNode.cs(15,33): warning CS0108: 'SkyNode.name' hides inherited member 'Object.name'. Use the new keyword if hiding was intended. [/storage/github/Scatterer/scatterer/scatterer.csproj]
/storage/github/Scatterer/scatterer/Effects/Proland/ProlandManager.cs(104,30): warning CS0618: 'Transform.FindChild(string)' is obsolete: 'FindChild has been deprecated. Use Find instead (UnityUpgradable) -> Find([mscorlib] System.String)' [/storage/github/Scatterer/scatterer/scatterer.csproj]
/storage/github/Scatterer/scatterer/Utilities/Shader/ShaderReplacer.cs(69,11): warning CS0618: 'WWW' is obsolete: 'Use UnityWebRequest, a fully featured replacement which is more efficient and has additional features' [/storage/github/Scatterer/scatterer/scatterer.csproj]
/storage/github/Scatterer/scatterer/Utilities/Shader/ShaderReplacer.cs(69,25): warning CS0618: 'WWW' is obsolete: 'Use UnityWebRequest, a fully featured replacement which is more efficient and has additional features' [/storage/github/Scatterer/scatterer/scatterer.csproj]
/storage/github/Scatterer/scatterer/Effects/Proland/Ocean/OceanFFTgpu.cs(517,4): warning CS0618: 'Random.seed' is obsolete: 'Deprecated. Use InitState() function or Random.state property instead.' [/storage/github/Scatterer/scatterer/scatterer.csproj]
/storage/github/Scatterer/scatterer/Effects/Proland/Ocean/OceanFFTcpu.cs(699,4): warning CS0618: 'Random.seed' is obsolete: 'Deprecated. Use InitState() function or Random.state property instead.' [/storage/github/Scatterer/scatterer/scatterer.csproj]
/storage/github/Scatterer/scatterer/Utilities/Misc/Utils.cs(77,12): warning CS0618: 'Transform.FindChild(string)' is obsolete: 'FindChild has been deprecated. Use Find instead (UnityUpgradable) -> Find([mscorlib] System.String)' [/storage/github/Scatterer/scatterer/scatterer.csproj]
/storage/github/Scatterer/scatterer/Effects/ScattererCelestialBodiesManager.cs(97,28): warning CS0618: 'Transform.FindChild(string)' is obsolete: 'FindChild has been deprecated. Use Find instead (UnityUpgradable) -> Find([mscorlib] System.String)' [/storage/github/Scatterer/scatterer/scatterer.csproj]
/storage/github/Scatterer/scatterer/Effects/ScattererCelestialBodiesManager.cs(100,25): warning CS0618: 'Transform.FindChild(string)' is obsolete: 'FindChild has been deprecated. Use Find instead (UnityUpgradable) -> Find([mscorlib] System.String)' [/storage/github/Scatterer/scatterer/scatterer.csproj]
  scatterer -> /storage/github/Scatterer/scatterer/bin/Debug/scatterer.dll

Build succeeded.

Then, changing public TemporalAntiAliasing() to public void Awake() fixes the above issue with the TemporalAntiAliasing exceptions.

BrettRyland commented 2 years ago

Also,

brett@br-workhorse:~/Games/KSP$ grep 'KSPCF.*[Ss]catterer' KSP.log
[LOG 22:55:00.700] [KSPCF:MemoryLeaks] A destroyed scatterer:RenderTypeFixer instance is owning a onGameSceneLoadRequested GameEvents callback. No action has been taken, but unless this mod is relying on this pattern, this is likely a memory leak.
[LOG 22:58:16.420] [KSPCF:MemoryLeaks] A destroyed scatterer:RenderTypeFixer instance is owning a onGameSceneLoadRequested GameEvents callback. No action has been taken, but unless this mod is relying on this pattern, this is likely a memory leak.
LGhassen commented 2 years ago

Thanks @BrettRyland I will add this change and take care of the RenderTypeFixer leak.

For the warnings I'm ignoring them as long as they don't cause any harm.

BrettRyland commented 2 years ago

Btw, there's another NRE that often shows up:

[EXC 14:27:32.738] NullReferenceException
        UnityEngine.Component.GetComponent[T] () (at <2425394cf09642369e2109953e31f62b>:0)
        Scatterer.SkyNode.OnDestroy () (at /storage/github/Scatterer/scatterer/Effects/Proland/Atmosphere/SkyNode.cs:794)
        UnityEngine.DebugLogHandler:LogException(Exception, Object)
        ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
        UnityEngine.Object:DestroyImmediate(Object)
        Scatterer.ProlandManager:OnDestroy() (at /storage/github/Scatterer/scatterer/Effects/Proland/ProlandManager.cs:272)
        Scatterer.ScattererCelestialBodiesManager:Cleanup() (at /storage/github/Scatterer/scatterer/Effects/ScattererCelestialBodiesManager.cs:183)
        Scatterer.Scatterer:OnDestroy() (at /storage/github/Scatterer/scatterer/Scatterer.cs:294)

The line

parentScaledTransform.GetComponent<MeshFilter> ().sharedMesh = originalScaledMesh;

in OnDestroy in SkyNode.cs should be checking that parentScaledTransform isn't null and that the result of the GetComponent call isn't null.

BrettRyland commented 2 years ago

And another one once the above one is fixed:

[EXC 14:37:31.532] NullReferenceException
        UnityEngine.Renderer.get_sharedMaterials () (at <2425394cf09642369e2109953e31f62b>:0)
        Scatterer.SkyNode.RestoreStockScaledTexture () (at /storage/github/Scatterer/scatterer/Effects/Proland/Atmosphere/SkyNode.cs:1060)
        Scatterer.SkyNode.OnDestroy () (at /storage/github/Scatterer/scatterer/Effects/Proland/Atmosphere/SkyNode.cs:800)
        UnityEngine.DebugLogHandler:LogException(Exception, Object)
        ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
        UnityEngine.Object:DestroyImmediate(Object)
        Scatterer.ProlandManager:OnDestroy() (at /storage/github/Scatterer/scatterer/Effects/Proland/ProlandManager.cs:272)
        Scatterer.ScattererCelestialBodiesManager:Cleanup() (at /storage/github/Scatterer/scatterer/Effects/ScattererCelestialBodiesManager.cs:183)
        Scatterer.Scatterer:OnDestroy() (at /storage/github/Scatterer/scatterer/Scatterer.cs:294)
gomker commented 1 year ago

Not sure if this thread is about any NRE spams , I am seeing a lot from scatterer.OceanNode.OnPreCull ( Related #45 )

[EXC 12:42:49.112] NullReferenceException: Object reference not set to an instance of an object
    scatterer.OceanNode.OnPreCull () (at <684aa87c0d2345f8a9e4739403f4afff>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

Seemed to happen when I was swithing up craft on Laythe.

Running latest scatter, can provide my full mod list / log if you think its needed.

StormCircuit commented 1 year ago

Not sure if this thread is about any NRE spams , I am seeing a lot from scatterer.OceanNode.OnPreCull ( Related #45 )

[EXC 12:42:49.112] NullReferenceException: Object reference not set to an instance of an object
  scatterer.OceanNode.OnPreCull () (at <684aa87c0d2345f8a9e4739403f4afff>:0)
  UnityEngine.DebugLogHandler:LogException(Exception, Object)
  ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
  UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

Seemed to happen when I was swithing up craft on Laythe.

Running latest scatter, can provide my full mod list / log if you think its needed.

I am also seeing these NRE's spammed near Laythe. I am getting them as far away as the surface of Vall.

azige commented 1 year ago

Not sure if this thread is about any NRE spams , I am seeing a lot from scatterer.OceanNode.OnPreCull ( Related #45 )

[EXC 12:42:49.112] NullReferenceException: Object reference not set to an instance of an object
  scatterer.OceanNode.OnPreCull () (at <684aa87c0d2345f8a9e4739403f4afff>:0)
  UnityEngine.DebugLogHandler:LogException(Exception, Object)
  ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
  UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

Seemed to happen when I was swithing up craft on Laythe.

Running latest scatter, can provide my full mod list / log if you think its needed.

I got same exceptions while flying a stock Kerbal X on Kerbin.

There are logs and other infomation, if it could help.

mooleshacat commented 7 months ago

I have same problem, NRE spam soooo bad on Kerbin that I cannot play the game. ExceptionDetector mod tells me its like 60 throws per second. It is hammering my SSD and creating 10GB+ log files. I see this has been open for 2 years, is there any progress on this issue?

[EXC 04:26:37.755] NullReferenceException: Object reference not set to an instance of an object
    scatterer.SunFlare.updateProperties () (at <684aa87c0d2345f8a9e4739403f4afff>:0)
    scatterer.SunflareCameraHook.OnPreRender () (at <684aa87c0d2345f8a9e4739403f4afff>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

log file: https://fastupload.io/rfwbTBCQMw9NuSX/file

Sorry I have no other place to upload the log :-/

Mod List:

[x] Science! Continued (xScienceContinued 6.0.2) Alarm Enhancements (AlarmEnhancements 1.0.2) Astronomer's Visual Pack (AstronomersVisualPack 3:v4.13) Astronomer's Visual Pack-2k Textures (AVP-2kTextures v1.13) Aviation Lights (AviationLights 1:v4.2.1.1) Blockland Space Program Flag (BlocklandSpaceProgramFlag v0) Breaking Ground (BreakingGround-DLC 1.7.1) Canadian Flags (CanadianFlags 1.0) ClickThrough Blocker (ClickThroughBlocker 1:2.1.10.21) Comfortable Landing (ComfortableLanding 2:2.0.2.5) Community Category Kit (CommunityCategoryKit v112.0.1) Community Delta-V Maps (CommunityDeltaVMaps 2:2.8) Community Parts Titles (CommunityPartsTitles 0.9.3) Community Parts Titles Extras: Categories (CommunityPartsTitlesExtrasCategory 0.9.3) Community Parts Titles Extras: CCK - No Duplicates (CommunityPartsTitlesExtrasNoCCKDup 0.9.3) Community Planet Enhancement: Laythe (CommunityPlanetEnhancementLaythe 1.0) Community Resource Pack (CommunityResourcePack v112.0.1) Community Tech Tree (CommunityTechTree 1:3.4.4) Community Terrain Texture Pack (CommunityTerrainTexturePack 1:1.0.5) Connected Living Space (ConnectedLivingSpace v2.0.2.0) ConstantTWR (ConstantTWR 0.0.5.4) Contract Configurator (ContractConfigurator v2.9.2.0) Danger Alerts Continued (DangerAlertsContinued 1.4.5.5) Decoupler Shroud (DecouplerShroud 0.8.1) Docking Cam (DockingCamKURS 1.3.8.5) Docking Port Alignment Indicator (DockingPortAlignmentIndicator 6.10.0.0) Dogecoin Flag (DogeCoinFlag v1.02) Draggable Altimeter (DraggableAltimeter v1.1.0) Draggable Controls (DraggableControls v1.0.0) Draggable Navball (DraggableNavball v1.0.1.5) Environmental Visual Enhancements Redux (EnvironmentalVisualEnhancements 3:1.11.7.1) EVA Handrails Continued (EVAHandrailsPackContinued 0.3.0.3) EvenMoarActionables (EvenMoarActionables 1.0.2) ExceptionDetectorUpdated (EDU) (ExceptionDetectorUpdated 0.1.1_alpha) Experiment Tracker (ExperimentTracker 1:v1.3.5.2) ExtraKerbin Moons (ExtraKerbinMoons 1.1) Federal Productions Flags (FederalProductions-Flags 0.2) Flag Pack (FlagPack v1.1.1) Free Launch Clamps (AlmostFreeLaunchClamps 0.3.1) GravityTurn Continued (GravityTurnContinued 3:1.8.4) Harmony 2 (Harmony2 2.2.1.0) Improved and Updated Chase Camera (ImprovedUpdatedChaseCam 1.6.4.3) IndicatorLights (IndicatorLights 1.8.3) K2 Command Pod Continued (K2CommandPodCont 1.1.11.1) Kerbal Engineer Redux (KerbalEngineerRedux 1.1.9.0) Kerbal GPS (KerbalGPSRevived 1.2.1.4) Kerbal Inventory System (KIS 1.29) Kerbal Joint Reinforcement Continued (KerbalJointReinforcementContinued v3.7.2.0) Kerbal Kountries (KerbalKountries v1.1) Kerbal Research & Development (KRnD 1.16.0.14) Kopernicus Expansion Continued-er (KopernicusExpansionContinueder Beta9.1.1) Kopernicus Expansion Continued-er Stock Configs (KopernicusExpansionContinueder-StockConfigs Beta9.1.1) Kopernicus Planetary System Modifier (Kopernicus 2:release-1.12.1-198) KSP Achievements (Achievements 1.10.1.8) KSP Community Fixes (KSPCommunityFixes 1.34.1) Landertrons (Landertron v1.3.0) LoreFriendly Serious Parody Flag Pack (LSPFlags v2.1) MagiCore (MagiCore 1.4.0.0) Making History (MakingHistory-DLC 1.12.1) Mini Airbrakes (MiniAirbrakes 1.1) Mini Sample Return Capsule (MSRC) by : CobaltWolf and AlbertKermin (MiniSampleReturnCapsule 1:1.4.3.0-release) Minor Planets Expansion (MinorPlanetsExpansion 1.0.8) Mk-X Spaceplane Parts (Mk-X 0.1.3.4) MoarActionables (MoarActionables 1.0) ModularFlightIntegrator (ModularFlightIntegrator 1.2.10.0) Module Manager (ModuleManager 4.2.3) Monero Flags (MoneroFlags 1:0.1.2.0) NG's Flags (NGsFlags 1.0) Notes (notes 0.17.0.0-adoption) OPM All-in-One KSPedia Delta-V Map (OPMAllinOneKSPediaDeltaVMap 1.0.1) Orbit's US Flag Pack (OrbitsUSFlagPack 2) Outer Planets Mod (OuterPlanetsMod 2:2.2.10) Patch Manager (PatchManager 0.0.17.6) Planet Wiki (PlanetWiki 1:4.1) Procedural Fairings (ProceduralFairings 1:v6.5.0.0) Procedural Fairings - For Everything! (ProceduralFairings-ForEverything v0.3.0) QuickRevert (QuickRevert 1:3.2.0.8) QuickSAS (QuickSAS 1:1.2.0.9) RCS Build Aid (RCSBuildAid v1.0.6) Scatterer (Scatterer 3:v0.0838) Scatterer Default Config (Scatterer-config 3:v0.0838) Scatterer Sunflare (Scatterer-sunflare 3:v0.0838) Science - Full Reward! (Continued) (Science-Full-Reward v5.2) Science - Full Transmit! (Science-Full-Transmit v1.1) Smart Parts (SmartParts 1.10) SpaceTux Library (SpaceTuxLibrary 0.0.8.5) SRCS - Stageable RCS (StageableRCS 1.2.2) Standard Propulsion Systems (StandardPropulsionSystems 1.0.6.1) Surface Mounted Lights (surfacelights 1.19) Toolbar (Toolbar 1:1.8.1.1) Toolbar Controller (ToolbarController 1:0.1.9.11) Tracking Lights (TrackingLights 1:0.0.3) TweakScale Rescaled (TweakScaleRescaled 3.2.2) TweakScale Rescaled Redistributable (TweakScaleRescaled-Redist 3.2.2) TweakScale Rescaled SafetyNet (TweakScaleRescaled-SafetyNet 3.2.2) VaporVent (VaporVent 1.1.12) Zive System (ZiveSystem 1.3)

Edit: I just noticed this was merged into main branch. My version of scatterer matches (v0.0838)

Maybe my NRE is slightly different?

LGhassen commented 7 months ago

@mooleshacat sorry but this is probably a config issue on your side seeing your list of mods. I'd say you have to find out which sunflare config is messed up, or which mod is causing it, or just disable sunflares.

LGhassen commented 2 months ago

These should be fixed on the latest version