fix(launch): fix no-sound when natives directory path contains non-ASCII characters - #6607
fix(launch): fix no-sound when natives directory path contains non-ASCII characters#6607Time-YiXian wants to merge 1 commit into
Conversation
|
上面这条评论是ai写的 我不怎么会英文 这里用我母语中文来个省流: 玩mite用小众加载器FishModLoader被中文路径bug肘了 然后看到之前有#1141修复方式 所以仿照着修了Windows上的中文路径问题。 |
…CII characters When the instance folder name contains non-ASCII characters (e.g. Chinese), the java.library.path is set to a path with those characters. JDK 17+ uses the ANSI-native API (LoadLibraryA) internally to resolve native libraries, which cannot handle non-ASCII paths - native libraries such as OpenAL32.dll fail to load, resulting in games launching with video but no audio. This is triggered when running 1.6.4 with FishModLoader, which depends on LWJGL 2.9.4, under JDK 17 with a Chinese-character instance folder name. Redirect getNativeFolder() to an ASCII-only temp path under java.io.tmpdir when the default path contains non-ASCII characters. This is the Windows equivalent of the existing Linux/macOS symlink workaround introduced in #1141. Fixes #1141 for Windows.
| private Path getNativeFolder() { | ||
| if (StringUtils.isBlank(options.getNativesDir())) { | ||
| return repository.getNativeDirectory(manifest.id(), options.getJava().getPlatform()); | ||
| Path defaultPath = repository.getNativeDirectory(manifest.id(), options.getJava().getPlatform()); |
There was a problem hiding this comment.
我不懂你为什么要改这里?而且既不检查 Java 版本,也不检查游戏版本,也不考多个仓库中相同实例 ID 发生冲突,就是强行把 native directory 修改掉。
|
原因是 FishModLoader这个模组加载器的 Main.main() 里调用了 System.setProperty("file.encoding", "UTF-8"),覆盖了 HMCL 设置-Dfile.encoding=GB18030,导致 JDK 17 的 LoadLibraryA 用 UTF-8 编码路径去匹配 GB18030 的 ANSI 代码页,路径乱码,OpenAL32.dll 加载失败。 改 getNativeFolder() 把 native 目录到ASCII 路径是我的简单的解决方法 PCL-CE 也是同样的做法。但是我不想在这里浪费时间了 关掉吧 其实最开始就有解决方法 就是用英文实例名..... 一键串门PCL-CE : |
|
不要为了特定模组加载器的 BUG 用一个 workaround 污染整个 Windows 平台的处理啊。 如果没有办法可靠的判断可能出问题的实例,那我更希望不引入这个 workaround。这个问题应该是 FishModLoader 自己的 BUG,首选的解决方案应该是让他们去修复问题。 |
When the instance folder name contains non-ASCII characters (e.g. Chinese),
the java.library.path is set to a path with those characters. JDK 17+ uses
the ANSI-native API (LoadLibraryA) internally to resolve native libraries,
which cannot handle non-ASCII paths — native libraries such as OpenAL32.dll
fail to load, resulting in games launching with video but no audio.
This is triggered when running 1.6.4 with FishModLoader, which depends on
LWJGL 2.9.4, under JDK 17 with a Chinese-character instance folder name.
Redirect getNativeFolder() to an ASCII-only temp path under java.io.tmpdir
when the default path contains non-ASCII characters. This is the Windows
equivalent of the existing Linux/macOS symlink workaround introduced in #1141.
Fixes #1141 for Windows.