Add BuildFontsAsync for parallel font/theme init

This commit is contained in:
2026-05-08 20:34:05 +02:00
parent daa800c8b1
commit ccc5a4e17a
2 changed files with 15 additions and 3 deletions
+13
View File
@@ -100,6 +100,19 @@ public class FontManager
JpRange = BuildRange(GlyphRangesJapanese.GlyphRanges);
}
/// <summary>
/// Async wrapper around <see cref="BuildFonts"/> for the Phase-1 LoadAsync
/// path. The font-atlas build is CPU-bound, so we offload via Task.Run and
/// honour the cancellation token at the scheduling boundary; this lets the
/// font build run in parallel with the theme init without blocking the
/// loader. Settings-driven manual rebuilds keep using the sync entry point.
/// </summary>
public async Task BuildFontsAsync(CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
await Task.Run(BuildFonts, cancellationToken).ConfigureAwait(false);
}
public void BuildFonts()
{
SetUpRanges();
+2 -3
View File
@@ -490,11 +490,10 @@ public sealed class Plugin : IAsyncDalamudPlugin
// Group A: Font + Theme parallel — both CPU-bound, independent, and
// dominate the load-time profile. Everything else stays sequential to
// keep ordering simple.
var fontTask = Task.Run(() =>
var fontTask = Task.Run(async () =>
{
FontManager = new FontManager();
// TODO(v1.4.x): replace with FontManager.BuildFontsAsync(cancellationToken)
FontManager.BuildFonts();
await FontManager.BuildFontsAsync(cancellationToken).ConfigureAwait(false);
}, cancellationToken);
var themeTask = Task.Run(() =>