Add some more logging to boot plugin loads

This commit is contained in:
goaaats 2025-05-07 22:40:05 +02:00
parent 5c5ce37a70
commit ac14d61a86

View file

@ -663,6 +663,8 @@ internal class PluginManager : IInternalDisposableService
_ = Task.Run( _ = Task.Run(
async () => async () =>
{ {
Log.Verbose("Starting async boot load");
// Load plugins that want to be loaded during Framework.Tick // Load plugins that want to be loaded during Framework.Tick
var framework = await Service<Framework>.GetAsync().ConfigureAwait(false); var framework = await Service<Framework>.GetAsync().ConfigureAwait(false);
await framework.RunOnTick( await framework.RunOnTick(
@ -671,10 +673,13 @@ internal class PluginManager : IInternalDisposableService
syncPlugins.Where(def => def.Manifest?.LoadRequiredState == 1), syncPlugins.Where(def => def.Manifest?.LoadRequiredState == 1),
tokenSource.Token), tokenSource.Token),
cancellationToken: tokenSource.Token).ConfigureAwait(false); cancellationToken: tokenSource.Token).ConfigureAwait(false);
Log.Verbose("Loaded FrameworkTickSync plugins (LoadRequiredState == 1)");
loadTasks.Add(LoadPluginsAsync( loadTasks.Add(LoadPluginsAsync(
"FrameworkTickAsync", "FrameworkTickAsync",
asyncPlugins.Where(def => def.Manifest?.LoadRequiredState == 1), asyncPlugins.Where(def => def.Manifest?.LoadRequiredState == 1),
tokenSource.Token)); tokenSource.Token));
Log.Verbose("Kicked off FrameworkTickAsync plugins (LoadRequiredState == 1)");
// Load plugins that want to be loaded during Framework.Tick, when drawing facilities are available // Load plugins that want to be loaded during Framework.Tick, when drawing facilities are available
_ = await Service<InterfaceManager.InterfaceManagerWithScene>.GetAsync().ConfigureAwait(false); _ = await Service<InterfaceManager.InterfaceManagerWithScene>.GetAsync().ConfigureAwait(false);
@ -684,14 +689,18 @@ internal class PluginManager : IInternalDisposableService
syncPlugins.Where(def => def.Manifest?.LoadRequiredState is 0 or null), syncPlugins.Where(def => def.Manifest?.LoadRequiredState is 0 or null),
tokenSource.Token), tokenSource.Token),
cancellationToken: tokenSource.Token); cancellationToken: tokenSource.Token);
Log.Verbose("Loaded DrawAvailableSync plugins (LoadRequiredState == 0 or null)");
loadTasks.Add(LoadPluginsAsync( loadTasks.Add(LoadPluginsAsync(
"DrawAvailableAsync", "DrawAvailableAsync",
asyncPlugins.Where(def => def.Manifest?.LoadRequiredState is 0 or null), asyncPlugins.Where(def => def.Manifest?.LoadRequiredState is 0 or null),
tokenSource.Token)); tokenSource.Token));
Log.Verbose("Kicked off DrawAvailableAsync plugins (LoadRequiredState == 0 or null)");
// Save signatures when all plugins are done loading, successful or not. // Save signatures when all plugins are done loading, successful or not.
try try
{ {
Log.Verbose("Now waiting for {NumTasks} async load tasks", loadTasks.Count);
await Task.WhenAll(loadTasks).ConfigureAwait(false); await Task.WhenAll(loadTasks).ConfigureAwait(false);
Log.Information("Loaded plugins on boot"); Log.Information("Loaded plugins on boot");
} }
@ -715,8 +724,13 @@ internal class PluginManager : IInternalDisposableService
} }
this.StartupLoadTracking = null; this.StartupLoadTracking = null;
}, }, tokenSource.Token).ContinueWith(t =>
tokenSource.Token); {
if (t.IsFaulted)
{
Log.Error(t.Exception, "Failed to load FrameworkTickAsync/DrawAvailableAsync plugins");
}
}, TaskContinuationOptions.OnlyOnFaulted);
} }
/// <summary> /// <summary>
@ -1831,18 +1845,27 @@ internal class PluginManager : IInternalDisposableService
_ = this.SetPluginReposFromConfigAsync(false); _ = this.SetPluginReposFromConfigAsync(false);
this.OnInstalledPluginsChanged += () => Task.Run(Troubleshooting.LogTroubleshooting); this.OnInstalledPluginsChanged += () => Task.Run(Troubleshooting.LogTroubleshooting);
Log.Information("[T3] PM repos OK!"); Log.Information("Repos loaded!");
} }
using (Timings.Start("PM Cleanup Plugins")) using (Timings.Start("PM Cleanup Plugins"))
{ {
this.CleanupPlugins(); this.CleanupPlugins();
Log.Information("[T3] PMC OK!"); Log.Information("Plugin cleanup OK!");
} }
using (Timings.Start("PM Load Sync Plugins")) using (Timings.Start("PM Load Sync Plugins"))
{ {
var loadAllPlugins = Task.Run(this.LoadAllPlugins); var loadAllPlugins = Task.Run(this.LoadAllPlugins)
.ContinueWith(t =>
{
if (t.IsFaulted)
{
Log.Error(t.Exception, "Error in LoadAllPlugins()");
}
_ = Task.Run(Troubleshooting.LogTroubleshooting);
});
// We wait for all blocking services and tasks to finish before kicking off the main thread in any mode. // We wait for all blocking services and tasks to finish before kicking off the main thread in any mode.
// This means that we don't want to block here if this stupid thing isn't enabled. // This means that we don't want to block here if this stupid thing isn't enabled.
@ -1852,10 +1875,8 @@ internal class PluginManager : IInternalDisposableService
loadAllPlugins.Wait(); loadAllPlugins.Wait();
} }
Log.Information("[T3] PML OK!"); Log.Information("Boot load started");
} }
_ = Task.Run(Troubleshooting.LogTroubleshooting);
} }
catch (Exception ex) catch (Exception ex)
{ {