0-byte icon files can hang loading
JonnyOThan opened this issue · 1 comments
JonnyOThan commented
I was helping someone on discord with their game which was hanging on load. The last thing in the logs is:
7993 [LOG 01:11:43.532] Load(Texture): SquadExpansion/MakingHistory/Parts/@thumbs/kv2Pod_icon
7994 [EXC 01:11:43.535] NullReferenceException: Object reference not set to an instance of an object
7995 KSPCommunityFixes.TextureLoaderOptimizations+<GetEnumerator>d__32.MoveNext () (at <0bab5addef684db2b081bb849763d334>:0)
7996 UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <12e76cd50cc64cf19e759e981cb725af>:0)
7997 UnityEngine.DebugLogHandler:LogException(Exception, Object)
7998 ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
7999 UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)
I'm not sure what was wrong with this file - I've seen other reports that occasionally the png files are 0 bytes long (possibly due to a crash/shutdown while generating them?). But in any case this function probably needs to be hardened against exceptions.
Update: confirmed that the file in question was 0 bytes, but not how it got like that.
JonnyOThan commented
huh, seems like the stock game also barfs on this, so maybe worth patching that too?
5254 [LOG 13:44:17.346] Load(Texture): SquadExpansion/MakingHistory/Parts/@thumbs/kv2Pod_icon
5255 [EXC 13:44:17.352] NullReferenceException: Object reference not set to an instance of an object
5256 DatabaseLoaderTexture_PNG+<Load>d__0.MoveNext () (at <39c0323fb6b449a4aaf3465c00ed3c8d>:0)
5257 UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <12e76cd50cc64cf19e759e981cb725af>:0)
5258 UnityEngine.DebugLogHandler:LogException(Exception, Object)
5259 ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
5260 UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)