Skip to content

Commit 005b285

Browse files
committed
Add timeout to splash to handle BepInEx failing to load
1 parent 8a6eed1 commit 005b285

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

BepInEx.SplashScreen.GUI/Program.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public static class Program
1616
{
1717
private static SplashScreen _mainForm;
1818

19+
private static readonly System.Timers.Timer _AliveTimer = new System.Timers.Timer(15000);
20+
1921
/// <summary>
2022
/// The main entry point for the application.
2123
/// </summary>
@@ -62,6 +64,23 @@ public static void Main(params string[] args)
6264
_mainForm.SetIcon(IconManager.GetLargeIcon(gameExecutable, true, true).ToBitmap());
6365

6466
BeginSnapPositionToGameWindow(gameProcess);
67+
68+
// If log messages stop coming, preloader/chainloader has crashed or is stuck
69+
_AliveTimer.AutoReset = false;
70+
_AliveTimer.Elapsed += (_, __) =>
71+
{
72+
try
73+
{
74+
Log("Stopped receiving log messages from the game, assuming preloader/chainloader has crashed or is stuck", true);
75+
}
76+
catch (Exception e)
77+
{
78+
// ¯\_(ツ)_/¯
79+
Debug.Fail(e.ToString());
80+
}
81+
Environment.Exit(3);
82+
};
83+
_AliveTimer.Start();
6584
}
6685
catch (Exception e)
6786
{
@@ -107,6 +126,10 @@ private static void InputReadingThread(object processArg)
107126
{
108127
while (inStream.CanRead && !gameProcess.HasExited)
109128
{
129+
// Still receiving log messages, so preloader/chainloader is still alive and loading
130+
_AliveTimer.Stop();
131+
_AliveTimer.Start();
132+
110133
ProcessInputMessage(inReader.ReadLine());
111134
}
112135
}

0 commit comments

Comments
 (0)