Skip to content
8 changes: 4 additions & 4 deletions packages/compass/src/main/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,13 @@ class CompassApplication {

await this.setupCORSBypass();
void this.setupCompassAuthService();
if (!process.env.CI || process.env.HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE) {
this.setupAutoUpdate();
}
await setupCSFLELibrary();
setupTheme(this);
this.setupJavaScriptArguments();
this.setupLifecycleListeners();
this.setupApplicationMenu();
this.setupWindowManager();
this.setupAutoUpdate();
this.trackApplicationLaunched(globalPreferences);
}

Expand Down Expand Up @@ -213,7 +211,9 @@ class CompassApplication {
}

private static setupAutoUpdate(): void {
CompassAutoUpdateManager.init(this);
if (!process.env.CI || process.env.HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE) {
void CompassAutoUpdateManager.init(this);
}
}

private static setupApplicationMenu(): void {
Expand Down
54 changes: 49 additions & 5 deletions packages/compass/src/main/auto-update-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,11 +827,53 @@ class CompassAutoUpdateManager {
this.setState(AutoUpdateManagerState.RestartDismissed);
}

private static _init(
private static checkForMismatchedMacOSArch() {
const mismatchedOnArm =
isMismatchedArchDarwin() && getSystemArch() === 'arm64';

if (!mismatchedOnArm) {
return;
}

void dialog
.showMessageBox({
Comment on lines +871 to +872
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the performance issue is bad enough that it deserves a system prompt and not a toast or something similar, but I'm open to the feedback here

icon: COMPASS_ICON,
message: 'Mismatched architecture detected',
detail:
'You are currently using a build of Compass that is not optimized for Apple Silicon processors. This version might have significat performance issues when used. ' +
'Would you like to download the version of Compass optimized for Apple Silicon processors now?',
buttons: [
'Download Compass for Apple Silicon (Recommended)',
'Not now',
],
cancelId: 1,
})
.then(({ response }) => {
if (response === 0) {
return dl.download(
BrowserWindow.getAllWindows()[0],
`https://compass.mongodb.com/api/v2/download/${this.autoUpdateOptions.version}/compass/${this.autoUpdateOptions.channel}/darwin-arm64`
);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change this to shell.openExternal I think, it's so slow that the in-app download is misbehaving

}
})
.catch((err) => {
log.warn(
mongoLogId(1_001_000_362),
'AutoUpdateManager',
'Failed to download Compass for a mismatched macos arch',
{ error: err.message }
);
});
}

private static async _init(
compassApp: typeof CompassApplication,
options: Partial<AutoUpdateManagerOptions> = {}
): void {
): Promise<void> {
await app.whenReady();

this.fetch = (url: string) => compassApp.httpClient.fetch(url);

compassApp.addExitHandler(() => {
this.stop();
return Promise.resolve();
Expand Down Expand Up @@ -867,6 +909,8 @@ class CompassAutoUpdateManager {
...options,
};

this.checkForMismatchedMacOSArch();

// TODO(COMPASS-7232): If auto-updates are not supported, then there is
// still a menu item to check for updates and then if it finds an update but
// auto-updates aren't supported it will still display a popup with an
Expand Down Expand Up @@ -961,13 +1005,13 @@ class CompassAutoUpdateManager {
);
}

static init(
static async init(
compassApp: typeof CompassApplication,
options: Partial<AutoUpdateManagerOptions> = {}
): void {
): Promise<void> {
if (!this.initCalled) {
this.initCalled = true;
this._init(compassApp, options);
await this._init(compassApp, options);
}
}

Expand Down
Loading