Skip to content

Commit

Permalink
fix: Try to fix crash from natives libraries on arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Feb 24, 2024
1 parent 2d17c03 commit 77e62a7
Show file tree
Hide file tree
Showing 25 changed files with 4,827 additions and 16 deletions.
26 changes: 21 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions xmcl-electron-app/main/definedPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { pluginClientToken } from '@xmcl/runtime/clientToken/pluginClientToken'
import { pluginCurseforgeClient } from '@xmcl/runtime/curseforge/pluginCurseforgeClient'
import { pluginEncodingWorker } from '@xmcl/runtime/encoding/pluginEncodingWorker'
import { pluginResourceWorker } from '@xmcl/runtime/resource/pluginResourceWorker'
import { pluginNativeReplacer } from '@xmcl/runtime/nativeReplacer/pluginNativeReplacer'
import { pluginFlights } from '@xmcl/runtime/flights'
import { pluginGFW } from '@xmcl/runtime/gfw/pluginGFW'
import { pluginImageStorage } from '@xmcl/runtime/imageStore/pluginImageStore'
Expand Down Expand Up @@ -48,6 +49,7 @@ export const definedPlugins: LauncherAppPlugin[] = [
pluginLaunchPrecheck,
pluginNvdiaGPULinux,
pluginUncaughtError,
pluginNativeReplacer,
elyByPlugin,

pluginMediaProtocol,
Expand Down
7 changes: 7 additions & 0 deletions xmcl-keystone-ui/locales/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,13 @@ setting:
remove: entfernen
repulse: Abwehren
particleModeDescription: Wählen Sie das Verhalten des Partikels beim Anklicken
replaceNative: Ersetzen Sie native Bibliotheken
replaceNativeDescription: >-
Ersetzen Sie native Bibliotheken entsprechend der Architektur Ihres
Computers.
replaceNatives:
all: Alle
legacy: Nur Legacy-Version
resetToDefault: Zurücksetzen auf den Standardwert
showRoot: ВідображатиAnzeige
theme:
Expand Down
5 changes: 5 additions & 0 deletions xmcl-keystone-ui/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,11 @@ setting:
remove: Remove
repulse: Repulse
particleModeDescription: Select the particle click behavior
replaceNative: Replace Native Libraries
replaceNativeDescription: Replace native libraries according to your computer's arch.
replaceNatives:
all: All
legacy: Legacy Version Only
resetToDefault: Reset to Default
showRoot: Show
theme:
Expand Down
6 changes: 6 additions & 0 deletions xmcl-keystone-ui/locales/es-ES.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ diagnosis:
missingAssetsIndex:
message: Launcher descargará el índice de assets por ti
name: Falta el archivo de índice de activos de {version}.
disable: Desactivar
errors:
DatabaseNotOpened: |-
¡La base de datos no está abierta!
Expand Down Expand Up @@ -898,6 +899,11 @@ setting:
remove: Eliminar
repulse: Repulsar
particleModeDescription: Selecciona el comportamiento al hacer clic en las partículas
replaceNative: Reemplazar bibliotecas nativas
replaceNativeDescription: Reemplace las bibliotecas nativas según el arco de su computadora.
replaceNatives:
all: Todo
legacy: Solo versión heredada
resetToDefault: Restablecer a los Valores Predeterminados
showRoot: Mostrar
theme:
Expand Down
8 changes: 8 additions & 0 deletions xmcl-keystone-ui/locales/fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ diagnosis:
missingVersionJar:
message: Cliquez pour installer cette version
name: Jar de version manquant pour Minecraft %{version}
disable: Désactiver
disk:
available: Disponible
used: Utilisé
Expand Down Expand Up @@ -1218,6 +1219,13 @@ setting:
remove: Éliminer
repulse: Repousser
particleModeDescription: Sélectionnez le comportement de clic des particules
replaceNative: Remplacer les bibliothèques natives
replaceNativeDescription: >-
Remplacez les bibliothèques natives en fonction de l'architecture de votre
ordinateur.
replaceNatives:
all: Tous
legacy: Version héritée uniquement
resetToDefault: Réinitialiser
showRoot: Afficher
theme:
Expand Down
6 changes: 6 additions & 0 deletions xmcl-keystone-ui/locales/gl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ diagnosis:
missingAssetsIndex:
message: O Lanzador descargará o índice de assets por ti
name: Falta o arquivo de índice de activos de {version}.
disable: Desactivar
instances:
addServerDescription: Isto creará un xogo que se lanzará directamente ao servidor.
launchBlocked:
Expand All @@ -239,3 +240,8 @@ setting:
maunalUpdateHint: |-
A versión non se pode actualizar automaticamente.
Volve descargar o iniciador do sitio web!
replaceNative: Substituír as bibliotecas nativas
replaceNativeDescription: Substitúe as bibliotecas nativas segundo o arco do teu ordenador.
replaceNatives:
all: Todos
legacy: Só a versión legada
6 changes: 6 additions & 0 deletions xmcl-keystone-ui/locales/ru.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ diagnosis:
missingVersionJar:
message: Нажмите, чтобы установить эту версию
name: Версия jar для Minecraft %{version} отсутсвует
disable: Запрещать
disk:
available: Доступно
used: Использовано
Expand Down Expand Up @@ -1139,6 +1140,11 @@ setting:
remove: Убрать
repulse: Репульс
particleModeDescription: Выберите поведение частицы при нажатии
replaceNative: Замените собственные библиотеки
replaceNativeDescription: Замените родные библиотеки в соответствии с аркой вашего компьютера.
replaceNatives:
all: Все
legacy: Только устаревшая версия
resetToDefault: Сброс к значению по умолчанию
showRoot: Отображать
theme:
Expand Down
5 changes: 5 additions & 0 deletions xmcl-keystone-ui/locales/uk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,11 @@ setting:
remove: Прибрати
repulse: Репульс
particleModeDescription: Виберіть поведінку частки при натисканні
replaceNative: Замінити рідні бібліотеки
replaceNativeDescription: Замініть рідні бібліотеки відповідно до арки вашого комп’ютера.
replaceNatives:
all: все
legacy: Лише застаріла версія
resetToDefault: Скидання до значення за промовчанням
showRoot: Відображати
theme:
Expand Down
5 changes: 5 additions & 0 deletions xmcl-keystone-ui/locales/zh-CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,11 @@ setting:
remove: 移除
repulse: 击退
particleModeDescription: 选择当你点击粒子时的特效
replaceNative: 替换库为 Native (原生)
replaceNativeDescription: 根据您的计算机架构替换本机库。
replaceNatives:
all: 全部
legacy: 仅旧版本
resetToDefault: 重置到默认配色
showRoot: 浏览
theme:
Expand Down
5 changes: 5 additions & 0 deletions xmcl-keystone-ui/src/composables/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ export function useSettings() {
get: () => state.value?.apiSetsPreference ?? '',
set: v => state.value?.apiSetsPreferenceSet(v),
})
const replaceNative = computed({
get: () => state.value?.replaceNatives ?? 'legacy-only' as string | false,
set: v => state.value?.replaceNativesSet(v as any),
})
const maxSockets = ref(state.value?.maxSockets)
const maxAPISockets = ref(state.value?.maxAPISockets)
const proxy = ref(getProxy())
Expand Down Expand Up @@ -189,6 +193,7 @@ export function useSettings() {
maxAPISockets,
locales,
proxy,
replaceNative,
selectedLocale,
apiSetsPreference,
apiSets,
Expand Down
22 changes: 22 additions & 0 deletions xmcl-keystone-ui/src/views/SettingGeneral.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
:title="t('setting.developerMode')"
:description="t('setting.developerModeDescription')"
/>
<SettingItemSelect
:select="replaceNative === false ? '' : replaceNative"
:title="t('setting.replaceNative')"
:description="t('setting.replaceNativeDescription')"
:items="replaceNativeItems"
@update:select="replaceNative = !$event ? false : $event"
/>
<SettingHeader>
🌐 {{ t('setting.network') }}
Expand Down Expand Up @@ -166,6 +173,7 @@ const {
apiSetsPreference,
selectedLocale,
maxSockets,
replaceNative,
disableTelemetry,
hideNews,
enableDiscord,
Expand All @@ -191,6 +199,20 @@ const apiSetItems = computed(() =>
}
})))
const locales = computed(() => rawLocales.value.map(({ locale, name }) => ({ text: name, value: locale })))
const replaceNativeItems = computed(() => [
{
text: t('disable'),
value: '',
},
{
text: t('setting.replaceNatives.legacy'),
value: 'legacy-only',
},
{
text: t('setting.replaceNatives.all'),
value: 'all',
},
])
const { show } = useDialog('migration')
const { root, showGameDirectory } = useGameDirectory()
Expand Down
9 changes: 9 additions & 0 deletions xmcl-runtime-api/src/entities/SettingSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@
"default": 16,
"type": "number"
},
"replaceNatives": {
"default": "legacy-only",
"enum": [
"all",
false,
"legacy-only"
]
},
"globalMinMemory": {
"default": 0,
"type": "number"
Expand Down Expand Up @@ -184,6 +192,7 @@
"linuxTitlebar",
"locale",
"maxSockets",
"replaceNatives",
"theme"
],
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
2 changes: 1 addition & 1 deletion xmcl-runtime-api/src/entities/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export interface Platform {
/**
* The direct output of `os.arch()`. Should look like x86 or x64.
*/
arch: 'x86' | 'x64' | string
arch: 'x64' | 'arm' | 'arm64' | 'ia32' | 'loong64' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 'riscv64' | 's390' | 's390x'
}
5 changes: 4 additions & 1 deletion xmcl-runtime-api/src/entities/setting.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ export interface SettingSchema {
* @default 16
*/
maxAPISockets?: number

/**
* @default "legacy-only"
*/
replaceNatives: 'all' | 'legacy-only' | false
/**
* @default 0
*/
Expand Down
6 changes: 6 additions & 0 deletions xmcl-runtime-api/src/entities/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class Settings implements SettingSchema {
*/
online = false
allowTurn = false
replaceNatives: 'all' | 'legacy-only' | false = 'legacy-only'

httpProxy = ''

Expand Down Expand Up @@ -83,6 +84,7 @@ export class Settings implements SettingSchema {
this.disableTelemetry = config.disableTelemetry
this.linuxTitlebar = config.linuxTitlebar
this.linuxEnableDedicatedGPUOptimization = config.linuxEnableDedicatedGPUOptimization
this.replaceNatives = config.replaceNatives
}

developerModeSet(developerMode: boolean) {
Expand Down Expand Up @@ -178,6 +180,10 @@ export class Settings implements SettingSchema {
this.linuxTitlebar = enabled
}

replaceNativesSet(replace: 'all' | 'legacy-only' | false) {
this.replaceNatives = replace
}

globalInstanceSetting(settings: {
globalMinMemory: number
globalMaxMemory: number
Expand Down
7 changes: 6 additions & 1 deletion xmcl-runtime-api/src/services/VersionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ export interface VersionService {
* This will not replace the existed files
*/
migrateMinecraftFile(): Promise<void>
resolveLocalVersion(versionFolder: string, root?: string): Promise<ResolvedVersion>
/**
* Resolve the local version from the version folder.
*
* @param versionFolder The version id
*/
resolveLocalVersion(versionFolder: string): Promise<ResolvedVersion>
/**
* Refresh a version in the version folder.
* @param versionFolder The version folder name. It must existed under the `versions` folder.
Expand Down
2 changes: 1 addition & 1 deletion xmcl-runtime/app/LauncherApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class LauncherApp extends EventEmitter {
this.platform = {
os: plat.name,
osRelease: plat.version,
arch: plat.arch,
arch: plat.arch as any,
}
this.appDataPath = join(appData, LAUNCHER_NAME)
this.minecraftDataPath = join(appData, this.platform.os === 'osx' ? 'minecraft' : '.minecraft')
Expand Down

0 comments on commit 77e62a7

Please sign in to comment.