ShotgunNinja / Kerbalism

Hundreds of Kerbals were killed in the making of this mod.
The Unlicense
43 stars 19 forks source link

Shaders asset bundle loading causing problems in HullcamVDS and Kronal Vessel Viewer #66

Closed linuxgurugamer closed 7 years ago

linuxgurugamer commented 7 years ago

Kerbalism is causing errors in HullcamVDS, in a very strange way. I temporarily fixed them, and am seeing errors from Kerbalism only in the configure area.

Log file: https://www.dropbox.com/s/yebdz2rq7s5ks4p/kerbalismErrors.zip?dl=0

Error fragment:

(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)

NullReferenceException: Object reference not set to an instance of an object at KERBALISM.Configure.configure () [0x00000] in :0 at KERBALISM.Configure.OnGUI () [0x00000] in :0

(Filename: Line: -1)

NullReferenceException: Object reference not set to an instance of an object at KERBALISM.Configure.configure () [0x00000] in :0 at KERBALISM.Configure.OnGUI () [0x00000] in :0

Somehow it's (among other things) causing a function in Hullcam to be called in an inappropriate manner.

I only took a brief look, but it seems that Kerbalism is trying to initialize/configure ALL modules that it finds. This is VERY intrusive, which is the intent, and if not done properly, causes issues.

ShotgunNinja commented 7 years ago

I'm trying to nail this down. Here's what I did:

Then looked at the log (that you can find here).

The exception in KERBALISM.Configure that you report is not there. If that is not weird enough, the exception being spammed instead is this one:

[EXC 23:31:11.521] NullReferenceException: Object reference not set to an instance of an object
HullcamVDS.CameraFilter.RenderTitlePage (Boolean title, UnityEngine.Texture2D titleTex)
HullcamVDS.MovieTimeFilter.OnRenderImage (UnityEngine.RenderTexture source, UnityEngine.RenderTexture target)

I investigated a bit and found out this interesting line here, also in the log:

[ERR 23:29:13.207] The AssetBundle 'file://C:/Games/KSP/KSP_x64_Data/../GameData/HullCameraVDS/Resources/shaders.bundle' can't be loaded because another AssetBundle with the same files is already loaded.

Then, looking at your source code in CameraFilter.RenderTitlePage (here), it seem to me that mtShader never got initialized in this case.

I then tried removing Kerbalism and see if the thing happened anyway. And it doesn't: everything work flawless, your code can load shader bundle and no exception is thrown.

So, I'm starting to think that this issue may be related to the fact that both our mods are loading shader bundles, somehow. Even if it doesn't really make sense why it should be a problem.

Anyway, I wasn't able to reproduce the exception you reported. I'm not sure what else I can try to check.

I only took a brief look, but it seems that Kerbalism is trying to initialize/configure ALL modules that it finds. This is VERY intrusive, which is the intent, and if not done properly, causes issues.

I want to clarify this. The Configure module is similar to the fuel switchers, instead it act as a module switcher. To switch modules, it simply disable the non-selected ones by setting their isEnabled field to false. Right now this is used exclusively to let the user choose only one process in the stock ISRU parts. That's it. No function is called in any stock or third-party modules. This was just to clarify and maybe it can help us both try to understand what's going on here.

ShotgunNinja commented 7 years ago

Good news, found the issue. It was the way I loaded the asset bundle containing my shaders... I'll include the fix in 1.1.9

ShotgunNinja commented 7 years ago

fixed here