feat(crash): show fabric mod confliction and missing.

This commit is contained in:
huanghongxun 2021-09-28 17:08:43 +08:00
parent e476460ab4
commit 8a9527bf38
10 changed files with 153 additions and 2 deletions

View File

@ -39,6 +39,7 @@ import org.jackhuang.hmcl.game.LogExporter;
import org.jackhuang.hmcl.launch.ProcessListener;
import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.ui.construct.TwoLineListItem;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.Log4jLevel;
import org.jackhuang.hmcl.util.Pair;
import org.jackhuang.hmcl.util.platform.Architecture;
@ -56,6 +57,8 @@ import java.util.List;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static org.jackhuang.hmcl.setting.ConfigHolder.config;
@ -134,6 +137,18 @@ public class GameCrashWindow extends Stage {
CrashReportAnalyzer.getJavaVersionFromMajorVersion(Integer.parseInt(result.getMatcher().group("expected")))))
.append("\n");
break;
case MOD_RESOLUTION_CONFLICT:
case MOD_RESOLUTION_MISSING:
reasonText.append(i18n("game.crash.reason." + result.getRule().name().toLowerCase(Locale.ROOT),
translateFabricModId(result.getMatcher().group("sourcemod")),
parseFabricModId(result.getMatcher().group("destmod")),
parseFabricModId(result.getMatcher().group("destmod"))));
break;
case MOD_RESOLUTION_MISSING_MINECRAFT:
reasonText.append(i18n("game.crash.reason." + result.getRule().name().toLowerCase(Locale.ROOT),
translateFabricModId(result.getMatcher().group("mod")),
result.getMatcher().group("version")));
break;
default:
reasonText.append(i18n("game.crash.reason." + result.getRule().name().toLowerCase(Locale.ROOT),
Arrays.stream(result.getRule().getGroupNames()).map(groupName -> result.getMatcher().group(groupName))
@ -152,7 +167,34 @@ public class GameCrashWindow extends Stage {
reason.set(reasonText.toString());
}
}
}, Schedulers.javafx());
}, Schedulers.javafx()).exceptionally(Lang::handleUncaughtException);
}
private static final Pattern FABRIC_MOD_ID = Pattern.compile("\\{(?<modid>.*?) @ (?<version>.*?)}");
private String translateFabricModId(String modName) {
switch (modName) {
case "fabric":
return "Fabric API";
case "minecraft":
return "Minecraft";
default:
return modName;
}
}
private String parseFabricModId(String modName) {
Matcher matcher = FABRIC_MOD_ID.matcher(modName);
if (matcher.find()) {
String modid = matcher.group("modid");
String version = matcher.group("version");
if ("[*]".equals(version)) {
return i18n("game.crash.reason.mod_resolution_mod_version.any", translateFabricModId(modid));
} else {
return i18n("game.crash.reason.mod_resolution_mod_version", translateFabricModId(modid), version);
}
}
return translateFabricModId(modName);
}
private void showLogWindow() {

View File

@ -342,6 +342,10 @@ game.crash.reason.loading_crashed_forge=Game cannot due to mod %1$s (%2$s) crash
game.crash.reason.loading_crashed_fabric=Game cannot due to mod %1$s crashed.\nYou can try to delete or update it.
game.crash.reason.mod=Game crashed because of the mod: %1$s.\nYou may update or delete the mod and try again.
game.crash.reason.mod_resolution=Game crashed because of mod resolution failure.\nFabric gives following information:\n%s
game.crash.reason.mod_resolution_conflict=Game crashed because of conflicted mods.\n%1$s conflicts with %2$s.
game.crash.reason.mod_resolution_missing=Game crashed because the mod that some mod depends on is not installed.\n%1$s requires mod to be installed: %2$s.\nThis means that you need to download %2$s from the download page or online websites.
game.crash.reason.mod_resolution_mod_version=%1$s (Version: %2$s)
game.crash.reason.mod_resolution_mod_version.any=%1$s (Any version)
game.crash.reason.no_class_def_found_error=Game cannot run because of incomplete code.\nYour game may be missing a mod, or some mod files may be incomplete.\nYou may need to reinstall the game and mods, or ask for help.\nMissing %1$s
game.crash.reason.no_such_method_error=Game cannot run because of incomplete code.\nYour game may be missing a mod, or some mod files may be incomplete.\nYou may need to reinstall the game and mods, or ask for help.
game.crash.reason.opengl_not_supported=Game cannot run because of a problem with your graphics driver.\nBecause OpenGL is not supported, are you in remote desktop or streaming mode? If yes, please use the original computer to start game.\nOr try to update your graphics driver to the latest version and restart game. If your computer has a discrete graphics, you need to check whether the game uses integrated/core graphics. If so, try to run HMCL and game using discrete graphics card. If you still have these problems, you may consider getting a new graphics card or a new computer.

View File

@ -342,6 +342,10 @@ game.crash.reason.loading_crashed_forge=當前遊戲因為模組 %1$s (%2$s) 錯
game.crash.reason.loading_crashed_fabric=當前遊戲因為模組 %1$s 錯誤,無法繼續運行。\n你可以嘗試刪除或更新該模組以解決問題。
game.crash.reason.mod=當前遊戲因為 %1$s 的問題,無法繼續運行。\n你可以更新或刪除已經安裝的 %1$s 再試。
game.crash.reason.mod_resolution=當前遊戲因為 Mod 依賴問題無法繼續運行。Fabric 提供了如下訊息:\n%1$s
game.crash.reason.mod_resolution_conflict=當前遊戲因為 Mod 衝突,無法繼續運行。\n%1$s 與 %2$s 不能相容。
game.crash.reason.mod_resolution_missing=當前遊戲因為缺少 Mod 前置,無法繼續運行。\n%1$s 需要前置 Mod%2$s 才能繼續運行。\n這表示你少安裝了 Mod或該 Mod 版本不夠。你可以到下載頁的模組下載,或到網路上下載 %2$s。
game.crash.reason.mod_resolution_mod_version=%1$s (版本號 %2$s)
game.crash.reason.mod_resolution_mod_version.any=%1$s (任意版本)
game.crash.reason.no_class_def_found_error=當前遊戲因為代碼不完整,無法繼續運行。\n你的遊戲可能缺失了某個 Mod或者某些 Mod 檔案不完整。\n你可能需要重新安裝遊戲和 Mod或請求他人幫助。\n缺失%1$s
game.crash.reason.no_such_method_error=當前遊戲因為代碼不完整,無法繼續運行。\n你的遊戲可能缺失了某個 Mod或者某些 Mod 檔案不完整。\n你可能需要重新安裝遊戲和 Mod或請求他人幫助。
game.crash.reason.opengl_not_supported=當前遊戲因為你的顯示卡驅動存在問題,無法繼續運行。\n原因是 OpenGL 不受支援,你現在是否在遠程桌面或者串流模式下?如果是,請直接使用原電腦啟動遊戲。\n或者嘗試升級你的顯示卡驅動到最新版本後再嘗試啟動遊戲。如果你的電腦存在獨立顯示卡你需要檢查遊戲是否使用集成/核心顯示卡啟動,如果是,請嘗試使用獨立顯示卡啟動 HMCL 與遊戲。如果仍有問題,你可能需要考慮換一個新顯示卡或新電腦。

View File

@ -342,6 +342,11 @@ game.crash.reason.loading_crashed_forge=当前游戏因为模组 %1$s (%2$s) 错
game.crash.reason.loading_crashed_fabric=当前游戏因为模组 %1$s 错误,无法继续运行。\n你可以尝试删除或更新该模组以解决问题。
game.crash.reason.mod=当前游戏因为 %1$s 的问题,无法继续运行。\n你可以更新或删除已经安装的 %1$s 再试。
game.crash.reason.mod_resolution=当前游戏因为 Mod 依赖问题无法继续运行。Fabric 提供了如下信息:\n%1$s
game.crash.reason.mod_resolution_conflict=当前游戏因为 Mod 冲突,无法继续运行。\n%1$s 与 %2$s 不能兼容。
game.crash.reason.mod_resolution_missing=当前游戏因为缺少 Mod 前置,无法继续运行。\n%1$s 需要前置 Mod%2$s 才能继续运行。\n这表示你少安装了 Mod或该 Mod 版本不够。你可以到下载页的模组下载,或到网上下载 %3$s。
game.crash.reason.mod_resolution_missing_minecraft=当前游戏因为 Mod 和 Minecraft 游戏版本不匹配,无法继续运行。\n%1$s 需要 Minecraft %2$s 才能运行。\n如果你要继续使用你已经安装的 Mod你可以选择安装对应的 Minecraft 版本;如果你要继续使用当前 Minecraft 版本,你需要安装对应版本的 Mod。
game.crash.reason.mod_resolution_mod_version=%1$s (版本号 %2$s)
game.crash.reason.mod_resolution_mod_version.any=%1$s (任意版本)
game.crash.reason.no_class_def_found_error=当前游戏因为代码不完整,无法继续运行。\n你的游戏可能缺失了某个 Mod或者某些 Mod 文件不完整。\n你可能需要重新安装游戏和 Mod或请求他人帮助。\n缺失%1$s
game.crash.reason.no_such_method_error=当前游戏因为代码不完整,无法继续运行。\n你的游戏可能缺失了某个 Mod或者某些 Mod 文件不完整。\n你可能需要重新安装游戏和 Mod或请求他人帮助。
game.crash.reason.opengl_not_supported=当前游戏因为你的显卡驱动存在问题,无法继续运行。\n原因是 OpenGL 不受支持,你现在是否在远程桌面或者串流模式下?如果是,请直接使用原电脑启动游戏。\n或者尝试升级你的显卡驱动到最新版本后再尝试启动游戏。如果你的电脑存在独立显卡你需要检查游戏是否使用集成/核心显卡启动,如果是,请尝试使用独立显卡启动 HMCL 与游戏。如果仍有问题,你可能需要考虑换一个新显卡或新电脑。

View File

@ -61,7 +61,11 @@ public final class CrashReportAnalyzer {
ILLEGAL_ACCESS_ERROR(Pattern.compile("java\\.lang\\.IllegalAccessError: tried to access class (.*?) from class (?<class>.*?)"), "class"),
// Some mods duplicated
DUPLICATED_MOD(Pattern.compile("Found a duplicate mod (?<name>.*) at (?<path>.*)"), "name", "path"),
// Fabric mod resolution
MOD_RESOLUTION(Pattern.compile("ModResolutionException: (?<reason>(.*)[\\n\\r]*( - (.*)[\\n\\r]*)+)"), "reason"),
MOD_RESOLUTION_CONFLICT(Pattern.compile("ModResolutionException: Found conflicting mods: (?<sourcemod>.*) conflicts with (?<destmod>.*)"), "sourcemod", "destmod"),
MOD_RESOLUTION_MISSING(Pattern.compile("ModResolutionException: Could not find required mod: (?<sourcemod>.*) requires (?<destmod>.*)"), "sourcemod", "destmod"),
MOD_RESOLUTION_MISSING_MINECRAFT(Pattern.compile("ModResolutionException: Could not find required mod: (?<mod>.*) requires \\{minecraft @ (?<version>.*)}"), "mod", "version"),
// Some mods require a file not existing, asking user to manually delete it
FILE_ALREADY_EXISTS(Pattern.compile("java\\.nio\\.file\\.FileAlreadyExistsException: (?<file>.*)"), "file"),
// Forge found some mod crashed in game loading

View File

@ -367,7 +367,8 @@ public final class Lang {
return null;
};
public static void handleUncaughtException(Throwable e) {
public static <R> R handleUncaughtException(Throwable e) {
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
return null;
}
}

View File

@ -247,6 +247,33 @@ public class CrashReportAnalyzerTest {
result.getMatcher().group("reason").replaceAll("\\s+", ""));
}
@Test
public void fabricConflicts() throws IOException {
CrashReportAnalyzer.Result result = findResultByRule(
CrashReportAnalyzer.anaylze(loadLog("/logs/fabric-mod-conflict.txt")),
CrashReportAnalyzer.Rule.MOD_RESOLUTION_CONFLICT);
Assert.assertEquals("phosphor", result.getMatcher().group("sourcemod"));
Assert.assertEquals("{starlight @ [*]}", result.getMatcher().group("destmod"));
}
@Test
public void fabricMissing() throws IOException {
CrashReportAnalyzer.Result result = findResultByRule(
CrashReportAnalyzer.anaylze(loadLog("/logs/fabric-mod-missing.txt")),
CrashReportAnalyzer.Rule.MOD_RESOLUTION_MISSING);
Assert.assertEquals("pca", result.getMatcher().group("sourcemod"));
Assert.assertEquals("{fabric @ [>=0.39.2]}", result.getMatcher().group("destmod"));
}
@Test
public void fabricMissingMinecraft() throws IOException {
CrashReportAnalyzer.Result result = findResultByRule(
CrashReportAnalyzer.anaylze(loadLog("/logs/fabric-minecraft.txt")),
CrashReportAnalyzer.Rule.MOD_RESOLUTION_MISSING_MINECRAFT);
Assert.assertEquals("fabric", result.getMatcher().group("mod"));
Assert.assertEquals("[~1.16.2-alpha.20.28.a]", result.getMatcher().group("version"));
}
@Test
public void customNpc() throws IOException {
CrashReportAnalyzer.Result result = findResultByRule(

View File

@ -0,0 +1,16 @@
[14:49:11] [main/INFO]: Loading for game Minecraft 1.17.1
[14:49:12] [main/FATAL]: A critical error occurred
net.fabricmc.loader.discovery.ModResolutionException: Could not find required mod: fabric requires {minecraft @ [~1.16.2-alpha.20.28.a]}
at net.fabricmc.loader.discovery.ModResolver.findCompatibleSet(ModResolver.java:198) ~[fabric-loader-0.11.7.jar:?]
at net.fabricmc.loader.discovery.ModResolver.resolve(ModResolver.java:832) ~[fabric-loader-0.11.7.jar:?]
at net.fabricmc.loader.FabricLoader.setup(FabricLoader.java:195) ~[fabric-loader-0.11.7.jar:?]
at net.fabricmc.loader.FabricLoader.load(FabricLoader.java:185) [fabric-loader-0.11.7.jar:?]
at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:132) [fabric-loader-0.11.7.jar:?]
at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:28) [fabric-loader-0.11.7.jar:?]
Caused by: net.fabricmc.loader.util.sat4j.specs.ContradictionException: Creating Empty clause ?
at net.fabricmc.loader.util.sat4j.minisat.constraints.cnf.Clauses.propagationCheck(Clauses.java:117) ~[fabric-loader-sat4j-2.3.5.4.jar:?]
at net.fabricmc.loader.util.sat4j.minisat.constraints.cnf.Clauses.sanityCheck(Clauses.java:97) ~[fabric-loader-sat4j-2.3.5.4.jar:?]
at net.fabricmc.loader.util.sat4j.minisat.constraints.MixedDataStructureDanielWL.createClause(MixedDataStructureDanielWL.java:81) ~[fabric-loader-sat4j-2.3.5.4.jar:?]
at net.fabricmc.loader.util.sat4j.minisat.core.Solver.addClause(Solver.java:401) ~[fabric-loader-sat4j-2.3.5.4.jar:?]
at net.fabricmc.loader.discovery.ModResolver.findCompatibleSet(ModResolver.java:195) ~[fabric-loader-0.11.7.jar:?]
... 5 more

View File

@ -0,0 +1,28 @@
[18:27:35] [main/INFO]: Loading for game Minecraft 1.16.5
[18:27:36] [ForkJoinPool-1-worker-7/WARN]: The mod "autoconfig1u" contains invalid entries in its mod json:
- Unsupported root entry "$schema" at line 2 column 14
[18:27:36] [ForkJoinPool-1-worker-2/WARN]: Non-Fabric mod JAR at "/storage/emulated/0/games/PojavLauncher/.minecraft/mods/stoneholm-1.16.52-1.2.2.jar", ignoring
[18:27:36] [ForkJoinPool-1-worker-4/WARN]: Non-Fabric mod JAR at "/storage/emulated/0/games/PojavLauncher/.minecraft/mods/OfflineSkins_1.16.5_v1a.jar", ignoring
[18:27:36] [ForkJoinPool-1-worker-6/WARN]: The mod "autoconfig1u" contains invalid entries in its mod json:
- Unsupported root entry "$schema" at line 2 column 14
[18:27:36] [ForkJoinPool-1-worker-2/WARN]: The mod "autoconfig1u" contains invalid entries in its mod json:
- Unsupported root entry "$schema" at line 2 column 14
[18:27:36] [ForkJoinPool-1-worker-7/WARN]: The mod "autoconfig1u" contains invalid entries in its mod json:
- Unsupported root entry "$schema" at line 2 column 14
[18:27:36] [ForkJoinPool-1-worker-6/WARN]: The mod "autoconfig1u" contains invalid entries in its mod json:
- Unsupported root entry "$schema" at line 2 column 14
[18:27:37] [main/FATAL]: A critical error occurred
net.fabricmc.loader.discovery.ModResolutionException: Found conflicting mods: phosphor conflicts with {starlight @ [*]}
at net.fabricmc.loader.discovery.ModResolver.findCompatibleSet(ModResolver.java:219) ~[fabric-loader-0.11.6.jar:?]
at net.fabricmc.loader.discovery.ModResolver.resolve(ModResolver.java:832) ~[fabric-loader-0.11.6.jar:?]
at net.fabricmc.loader.FabricLoader.setup(FabricLoader.java:195) ~[fabric-loader-0.11.6.jar:?]
at net.fabricmc.loader.FabricLoader.load(FabricLoader.java:185) [fabric-loader-0.11.6.jar:?]
at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:132) [fabric-loader-0.11.6.jar:?]
at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:28) [fabric-loader-0.11.6.jar:?]
Caused by: net.fabricmc.loader.util.sat4j.specs.ContradictionException: Creating Empty clause ?
at net.fabricmc.loader.util.sat4j.minisat.constraints.cnf.Clauses.propagationCheck(Clauses.java:117) ~[fabric-loader-sat4j-2.3.5.4.jar:?]
at net.fabricmc.loader.util.sat4j.minisat.constraints.cnf.Clauses.sanityCheck(Clauses.java:97) ~[fabric-loader-sat4j-2.3.5.4.jar:?]
at net.fabricmc.loader.util.sat4j.minisat.constraints.MixedDataStructureDanielWL.createClause(MixedDataStructureDanielWL.java:81) ~[fabric-loader-sat4j-2.3.5.4.jar:?]
at net.fabricmc.loader.util.sat4j.minisat.core.Solver.addClause(Solver.java:401) ~[fabric-loader-sat4j-2.3.5.4.jar:?]
at net.fabricmc.loader.discovery.ModResolver.findCompatibleSet(ModResolver.java:216) ~[fabric-loader-0.11.6.jar:?]
... 5 more

View File

@ -0,0 +1,20 @@
OpenJDK 64-Bit Server VM warning: Option --illegal-access is deprecated and will be removed in a future release.
[16:18:52] [main/INFO]: Loading for game Minecraft 1.17.1
[16:18:52] [main/INFO]: Fabric is preparing JARs on first launch, this may take a few seconds...
[16:18:55] [ForkJoinPool-1-worker-17/WARN]: The mod "autoconfig1u" contains invalid entries in its mod json:
- Unsupported root entry "$schema" at line 2 column 14
[16:18:55] [main/FATAL]: A critical error occurred
net.fabricmc.loader.discovery.ModResolutionException: Could not find required mod: pca requires {fabric @ [>=0.39.2]}
at net.fabricmc.loader.discovery.ModResolver.findCompatibleSet(ModResolver.java:198) ~[fabric-loader-0.11.7.jar:?]
at net.fabricmc.loader.discovery.ModResolver.resolve(ModResolver.java:832) ~[fabric-loader-0.11.7.jar:?]
at net.fabricmc.loader.FabricLoader.setup(FabricLoader.java:195) ~[fabric-loader-0.11.7.jar:?]
at net.fabricmc.loader.FabricLoader.load(FabricLoader.java:185) [fabric-loader-0.11.7.jar:?]
at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:132) [fabric-loader-0.11.7.jar:?]
at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:28) [fabric-loader-0.11.7.jar:?]
Caused by: net.fabricmc.loader.util.sat4j.specs.ContradictionException: Creating Empty clause ?
at net.fabricmc.loader.util.sat4j.minisat.constraints.cnf.Clauses.propagationCheck(Clauses.java:117) ~[fabric-loader-sat4j-2.3.5.4.jar:?]
at net.fabricmc.loader.util.sat4j.minisat.constraints.cnf.Clauses.sanityCheck(Clauses.java:97) ~[fabric-loader-sat4j-2.3.5.4.jar:?]
at net.fabricmc.loader.util.sat4j.minisat.constraints.MixedDataStructureDanielWL.createClause(MixedDataStructureDanielWL.java:81) ~[fabric-loader-sat4j-2.3.5.4.jar:?]
at net.fabricmc.loader.util.sat4j.minisat.core.Solver.addClause(Solver.java:401) ~[fabric-loader-sat4j-2.3.5.4.jar:?]
at net.fabricmc.loader.discovery.ModResolver.findCompatibleSet(ModResolver.java:195) ~[fabric-loader-0.11.7.jar:?]
... 5 more