Wrap font texture upload in try/catch and log/retry in 4k x 4k on exception (#843)

This commit is contained in:
kizer 2022-05-16 18:07:58 +09:00 committed by GitHub
parent a241e646b6
commit 0971100696
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 2 deletions

View file

@ -1012,7 +1012,36 @@ namespace Dalamud.Interface.Internal
Log.Verbose("[FONT] RebuildFontsInternal() detaching");
this.scene.OnNewRenderFrame -= this.RebuildFontsInternal;
this.scene.InvalidateFonts();
Log.Verbose("[FONT] Calling InvalidateFonts");
try
{
this.scene.InvalidateFonts();
}
catch (Exception ex)
{
if (this.FontResolutionLevel > 2)
{
Log.Error(ex, "[FONT] Failed to create font textures; setting font resolution level to 2 and retrying");
this.FontResolutionLevelOverride = 2;
this.SetupFonts();
}
else
{
Log.Error(ex, "[FONT] Failed to create font textures; forcing fallback font mode");
this.SetupFonts(true);
}
Log.Verbose("[FONT] Calling InvalidateFonts again");
try
{
this.scene.InvalidateFonts();
}
catch (Exception ex2)
{
Log.Error(ex2, "[FONT] Giving up");
}
}
Log.Verbose("[FONT] Font Rebuild OK!");

View file

@ -367,6 +367,8 @@ namespace Dalamud.Interface.Internal.Windows
ImGuiHelpers.ScaledDummy(3);
ImGui.Text(Loc.Localize("DalamudSettingsFontResolutionLevel", "Font resolution level"));
if (interfaceManager.FontResolutionLevelOverride != null)
this.fontResolutionLevel = interfaceManager.FontResolutionLevelOverride.Value;
if (ImGui.Combo("##DalamudSettingsFontResolutionLevelCombo", ref this.fontResolutionLevel, this.fontResolutionLevelStrings, this.fontResolutionLevelStrings.Length))
{
interfaceManager.FontResolutionLevelOverride = this.fontResolutionLevel;
@ -377,7 +379,7 @@ namespace Dalamud.Interface.Internal.Windows
ImGui.TextWrapped(string.Format(
Loc.Localize(
"DalamudSettingsFontResolutionLevelHint",
"This option allows Dalamud fonts to look better.\n* If your game crashes right away when changing this option, your PC does not support high font resolutions in Dalamud - you will have to use a lower one.\n* If it doesn't crash immediately, then you can keep the new choice indefinitely as it's not going to crash your game once it worked.\n* Either choose the 3rd or 5th option. Use other options only when neither works well.\n* Current font atlas size is {0}px * {1}px."),
"This option allows Dalamud fonts to look better.\n* If your game crashes right away, or the option reverts, when changing this option, your PC does not support high font resolutions in Dalamud - you will have to use a lower one.\n* If it doesn't crash or revert immediately, then you can keep the new choice indefinitely as it's not going to crash your game once it worked.\n* Either choose the 3rd or 5th option. Use other options only when neither works well.\n* Current font atlas size is {0}px * {1}px."),
ImGui.GetIO().Fonts.TexWidth,
ImGui.GetIO().Fonts.TexHeight));
ImGui.PopStyleColor();