Skip to content

Commit

Permalink
Add timeout to splash to handle BepInEx failing to load
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Dec 27, 2023
1 parent 8a6eed1 commit 005b285
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions BepInEx.SplashScreen.GUI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public static class Program
{
private static SplashScreen _mainForm;

private static readonly System.Timers.Timer _AliveTimer = new System.Timers.Timer(15000);

/// <summary>
/// The main entry point for the application.
/// </summary>
Expand Down Expand Up @@ -62,6 +64,23 @@ public static void Main(params string[] args)
_mainForm.SetIcon(IconManager.GetLargeIcon(gameExecutable, true, true).ToBitmap());

BeginSnapPositionToGameWindow(gameProcess);

// If log messages stop coming, preloader/chainloader has crashed or is stuck
_AliveTimer.AutoReset = false;
_AliveTimer.Elapsed += (_, __) =>
{
try
{
Log("Stopped receiving log messages from the game, assuming preloader/chainloader has crashed or is stuck", true);
}
catch (Exception e)
{
// ¯\_(ツ)_/¯
Debug.Fail(e.ToString());
}
Environment.Exit(3);
};
_AliveTimer.Start();
}
catch (Exception e)
{
Expand Down Expand Up @@ -107,6 +126,10 @@ private static void InputReadingThread(object processArg)
{
while (inStream.CanRead && !gameProcess.HasExited)
{
// Still receiving log messages, so preloader/chainloader is still alive and loading
_AliveTimer.Stop();
_AliveTimer.Start();

ProcessInputMessage(inReader.ReadLine());
}
}
Expand Down

0 comments on commit 005b285

Please sign in to comment.