Skip to content

WIP Fix Private API causing crashes on macOS Ventura #708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/server/src/server/api/privateApi/PrivateApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Sema } from "async-sema";
import { clamp, isEmpty, isNotEmpty } from "@server/helpers/utils";
import { TransactionPromise, TransactionResult } from "@server/managers/transactionManager/transactionPromise";
import { TransactionManager } from "@server/managers/transactionManager";
import { execSync } from "child_process";

import { MAX_PORT, MIN_PORT } from "./Constants";
import { PrivateApiEventHandler } from "./eventHandlers";
Expand Down Expand Up @@ -105,6 +106,9 @@ export class PrivateApiService extends Loggable {
this.log.debug("Starting Private API Helper Services...");
await this.configureServer();

// Execute the boot argument command if conditions are met
this.setBootArgs();

// we need to get the port to open the server on (to allow multiple users to use the bundle)
// we'll base this off the users uid (a unique id for each user, starting from 501)
// we'll subtract 501 to get an id starting at 0, incremented for each user
Expand Down Expand Up @@ -408,4 +412,19 @@ export class PrivateApiService extends Loggable {
await this.mode?.stop();
this.log.info(`Private API Helper Stopped...`);
}

private setBootArgs() {
const osVersion = os.release();
const isM1Mac = os.cpus().some(cpu => cpu.model.includes("Apple M1"));
const isVentura = osVersion.startsWith("22.");

if (isM1Mac && isVentura) {
try {
execSync("sudo nvram boot-args=-arm64e_preview_abi");
this.log.info("Successfully set boot-args for macOS Ventura on M1 Mac.");
} catch (error) {
this.log.error("Failed to set boot-args for macOS Ventura on M1 Mac:", error);
}
}
}
}