Merge pull request #11 from sanasol/hotfix/macos-code-sign-sentry-disable

Fix: macOS build crash on game launch and server not booting
This commit is contained in:
AMIAY
2026-01-17 15:07:28 +01:00
committed by GitHub

View File

@@ -737,6 +737,73 @@ async function launchGame(playerName = 'Player', progressCallback, javaPathOverr
throw new Error(`Game client missing. Tried: ${attempted}`); throw new Error(`Game client missing. Tried: ${attempted}`);
} }
// macOS: Remove quarantine and ad-hoc sign binaries to prevent SIGABRT crashes
if (process.platform === 'darwin') {
try {
const appBundle = path.join(gameLatest, 'Client', 'Hytale.app');
const serverDir = path.join(gameLatest, 'Server');
// Helper to remove quarantine and sign a path
const signPath = async (targetPath, deep = false) => {
await execAsync(`xattr -cr "${targetPath}"`).catch(() => {});
const deepFlag = deep ? '--deep ' : '';
await execAsync(`codesign --force ${deepFlag}--sign - "${targetPath}"`).catch(() => {});
};
// Sign app bundle or client binary
if (fs.existsSync(appBundle)) {
await signPath(appBundle, true);
console.log('Signed macOS app bundle');
} else {
await signPath(path.dirname(clientPath), true);
console.log('Signed macOS client binary');
}
// Sign Java runtime
if (javaBin && fs.existsSync(javaBin)) {
// Navigate from bin/java up to the JRE bundle root (contains Contents/)
let jreRoot = path.dirname(path.dirname(javaBin));
if (jreRoot.endsWith('Home')) {
jreRoot = path.dirname(path.dirname(jreRoot));
}
await signPath(jreRoot, true);
await signPath(javaBin, false);
console.log('Signed Java runtime');
}
// Sign server directory native libraries
if (fs.existsSync(serverDir)) {
await execAsync(`xattr -cr "${serverDir}"`).catch(() => {});
await execAsync(`find "${serverDir}" -type f -perm +111 -exec codesign --force --sign - {} \\;`).catch(() => {});
console.log('Signed server binaries');
}
// Create java wrapper script that adds --disable-sentry flag for server launches
if (javaBin && fs.existsSync(javaBin)) {
const javaWrapperPath = path.join(path.dirname(javaBin), 'java-wrapper');
const wrapperScript = `#!/bin/bash
# Java wrapper for macOS - adds --disable-sentry to fix Sentry hang issue
REAL_JAVA="${javaBin}"
ARGS=("$@")
for i in "\${!ARGS[@]}"; do
if [[ "\${ARGS[$i]}" == *"HytaleServer.jar"* ]]; then
ARGS=("\${ARGS[@]:0:$((i+1))}" "--disable-sentry" "\${ARGS[@]:$((i+1))}")
break
fi
done
exec "$REAL_JAVA" "\${ARGS[@]}"
`;
fs.writeFileSync(javaWrapperPath, wrapperScript, { mode: 0o755 });
await signPath(javaWrapperPath, false);
console.log('Created java wrapper with --disable-sentry fix');
javaBin = javaWrapperPath;
}
} catch (signError) {
console.log('Notice: macOS signing step failed:', signError.message);
console.log('The game may still launch if Gatekeeper allows it');
}
}
const uuid = getUuidForUser(playerName); const uuid = getUuidForUser(playerName);
const args = [ const args = [
'--app-dir', gameLatest, '--app-dir', gameLatest,