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

FastLoader allow the game to launch even when unrecoverable errors happens #133

Closed
gotmachine opened this issue Mar 29, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@gotmachine
Copy link
Contributor

Consider the following PartModule :

public class GetInfoThrowModule : PartModule
{
    public override string GetInfo()
    {
        throw new Exception("ExceptionFromGetInfo");
    }
}

In stock, attempting to launch the game with such a module will cause the whole cascade of the loader coroutines to stop executing on that exception, with the loading process getting "stuck" :

[EXC 13:31:33.763] Exception: ExceptionFromGetInfo
	KSPCommunityFixes.Performance.GetInfoThrowModule.GetInfo ()
	PartLoader.CompilePartInfo (AvailablePart newPartInfo, Part part)
	PartLoader+<CompileParts>d__56.MoveNext ()
	UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress)
	UnityEngine.DebugLogHandler:LogException(Exception, Object)
	ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
	UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

The KSPCF loader manually execute those coroutines and try/catch exceptions in MoveNext(), also stopping the execution. However, it doesn't propagate that downward the whole loading process. So an exception in the part loader coroutine stack will crash the part loader, but not the rest of the loading process, resulting in the game proceeding as if nothing happened to the main menu, but with a lot of stuff missing, which obviously doesn't end well when the user try to load a save.

[EXC 13:25:03.383] Exception: ExceptionFromGetInfo
	KSPCommunityFixes.Performance.GetInfoThrowModule.GetInfo ()
	PartLoader.CompilePartInfo (AvailablePart newPartInfo, Part part)
	(wrapper dynamic-method) PartLoader+<CompileParts>d__56.PartLoader+<CompileParts>d__56.MoveNext_Patch0(PartLoader/<CompileParts>d__56)
	KSPCommunityFixes.Performance.KSPCFFastLoader+<FrameUnlockedCoroutine>d__61.MoveNext ()
	UnityEngine.DebugLogHandler:LogException(Exception, Object)
	ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
	UnityEngine.Debug:LogException(Exception)
	KSPCommunityFixes.Performance.<FrameUnlockedCoroutine>d__61:MoveNext()
	KSPCommunityFixes.Performance.<PartLoader_CompileAll>d__57:MoveNext()
	UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

We should definitely reproduce the stock behavior of preventing the game to load in such cases.
As a bonus, it would be nice to show a popup with the exception/stacktrace to help people troubleshot their install.

@gotmachine gotmachine added the bug Something isn't working label Mar 29, 2023
@gotmachine
Copy link
Contributor Author

Ok, that should do I guess :
image

gotmachine added a commit that referenced this issue Mar 29, 2023
…hen unrecoverable errors happen during loading.
gotmachine added a commit that referenced this issue Mar 29, 2023
…nservative, causing loading to stop on exceptions that don't cause a fatal error in stock.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant