Skip to content
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

[PS-1196] Add option to disable hardware acceleration #2896

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions apps/desktop/src/app/accounts/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,23 @@ <h2>
"enableBrowserIntegrationFingerprintDesc" | i18n
}}</small>
</div>
<div class="form-group">
<div class="checkbox">
<label for="enableHardwareAcceleration">
<input
id="enableHardwareAcceleration"
type="checkbox"
name="EnableHardwareAcceleration"
[(ngModel)]="enableHardwareAcceleration"
(change)="saveHardwareAcceleration()"
/>
{{ "enableHardwareAcceleration" | i18n }}
</label>
</div>
<small class="help-block">
{{ "enableHardwareAccelerationDesc" | i18n }}
</small>
</div>
<div class="form-group">
<label for="theme">{{ "theme" | i18n }}</label>
<select id="theme" name="Theme" [(ngModel)]="theme" (change)="saveTheme()">
Expand Down
14 changes: 14 additions & 0 deletions apps/desktop/src/app/accounts/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class SettingsComponent implements OnInit {
vaultTimeoutAction: string;
pin: boolean = null;
disableFavicons = false;
enableHardwareAcceleration = false;
enableBrowserIntegration = false;
enableBrowserIntegrationFingerprint = false;
enableMinToTray = false;
Expand Down Expand Up @@ -56,6 +57,8 @@ export class SettingsComponent implements OnInit {
enableMinToTrayDescText: string;
enableCloseToTrayText: string;
enableCloseToTrayDescText: string;
enableHardwareAccelerationText: string;
enableHardwareAccelerationDescText: string;
Comment on lines +60 to +61
Copy link
Member

Choose a reason for hiding this comment

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

These should be unnecessary since we don't need to conditionally change what text is shown.

startToTrayText: string;
startToTrayDescText: string;

Expand Down Expand Up @@ -97,6 +100,12 @@ export class SettingsComponent implements OnInit {
this.startToTrayText = this.i18nService.t(startToTrayKey);
this.startToTrayDescText = this.i18nService.t(startToTrayKey + "Desc");

const enableHardwareAccelerationKey = "enableHardwareAcceleration";
this.enableHardwareAccelerationText = this.i18nService.t(enableHardwareAccelerationKey);
this.enableHardwareAccelerationDescText = this.i18nService.t(
enableHardwareAccelerationKey + "Desc"
);

Comment on lines +103 to +108
Copy link
Member

Choose a reason for hiding this comment

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

Once 60-61 is removed, this also needs to be removed.

this.vaultTimeouts = [
// { name: i18nService.t('immediately'), value: 0 },
{ name: i18nService.t("oneMinute"), value: 1 },
Expand Down Expand Up @@ -155,6 +164,7 @@ export class SettingsComponent implements OnInit {
this.enableCloseToTray = await this.stateService.getEnableCloseToTray();
this.enableTray = await this.stateService.getEnableTray();
this.startToTray = await this.stateService.getEnableStartToTray();
this.enableHardwareAcceleration = await this.stateService.getEnableHardwareAcceleration();

this.alwaysShowDock = await this.stateService.getAlwaysShowDock();
this.showAlwaysShowDock = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop;
Expand Down Expand Up @@ -415,4 +425,8 @@ export class SettingsComponent implements OnInit {
this.enableBrowserIntegrationFingerprint
);
}

async saveHardwareAcceleration() {
await this.stateService.setEnableHardwareAcceleration(this.enableHardwareAcceleration);
}
}
6 changes: 6 additions & 0 deletions apps/desktop/src/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,12 @@
"enableTrayDesc": {
"message": "Always show an icon in the system tray."
},
"enableHardwareAcceleration": {
"message": "Enable hardware acceleration"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"message": "Enable hardware acceleration"
"message": "Use hardware acceleration"

},
"enableHardwareAccelerationDesc": {
"message": "Enable the application to make use of a discrete GPU. Restart is required."
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"message": "Enable the application to make use of a discrete GPU. Restart is required."
"message": "By default this setting is on. Turn off only if you experience graphical issues. Restart is required."

},
"startToTray": {
"message": "Start To Tray Icon"
},
Expand Down
6 changes: 6 additions & 0 deletions apps/desktop/src/locales/en_GB/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,12 @@
"enableTrayDesc": {
"message": "Always show an icon in the system tray."
},
"enableHardwareAcceleration": {
Copy link
Member

Choose a reason for hiding this comment

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

Please only change the en locale. The other locales are generated by the crowdin integration.

"message": "Enable hardware acceleration"
},
"enableHardwareAccelerationDesc": {
"message": "Enable the application to make use of a discrete GPU. Restart is required."
},
"startToTray": {
"message": "Start to tray icon"
},
Expand Down
6 changes: 6 additions & 0 deletions apps/desktop/src/locales/en_IN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,12 @@
"enableTrayDesc": {
"message": "Always show an icon in the system tray."
},
"enableHardwareAcceleration": {
Copy link
Member

Choose a reason for hiding this comment

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

Please only change the en locale. The other locales are generated by the crowdin integration.

"message": "Enable hardware acceleration"
},
"enableHardwareAccelerationDesc": {
"message": "Enable the application to make use of a discrete GPU. Restart is required."
},
"startToTray": {
"message": "Start to tray icon"
},
Expand Down
9 changes: 9 additions & 0 deletions apps/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export class Main {
}

bootstrap() {
this.toggleHardwareAcceleration();
this.desktopCredentialStorageListener.init();
this.windowMain.init().then(
async () => {
Expand Down Expand Up @@ -215,4 +216,12 @@ export class Main {
}
});
}

private async toggleHardwareAcceleration(): Promise<void> {
const enableHardwareEnableAcceleration =
await this.stateService.getEnableHardwareAcceleration();
if (!enableHardwareEnableAcceleration) {
app.disableHardwareAcceleration();
}
}
}
2 changes: 2 additions & 0 deletions libs/common/src/abstractions/state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ export abstract class StateService<T extends Account = Account> {
setEnableStartToTray: (value: boolean, options?: StorageOptions) => Promise<void>;
getEnableTray: (options?: StorageOptions) => Promise<boolean>;
setEnableTray: (value: boolean, options?: StorageOptions) => Promise<void>;
getEnableHardwareAcceleration: (options?: StorageOptions) => Promise<boolean>;
setEnableHardwareAcceleration: (value: boolean, options?: StorageOptions) => Promise<void>;
getEncryptedCiphers: (options?: StorageOptions) => Promise<{ [id: string]: CipherData }>;
setEncryptedCiphers: (
value: { [id: string]: CipherData },
Expand Down
1 change: 1 addition & 0 deletions libs/common/src/models/domain/globalState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ export class GlobalState {
alwaysShowDock?: boolean;
enableBrowserIntegration?: boolean;
enableBrowserIntegrationFingerprint?: boolean;
enableHardwareAcceleration?: boolean;
}
18 changes: 18 additions & 0 deletions libs/common/src/services/state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,24 @@ export class StateService<
);
}

async getEnableHardwareAcceleration(options?: StorageOptions): Promise<boolean> {
return (
(await this.getGlobals(this.reconcileOptions(options, await this.defaultOnDiskOptions())))
?.enableHardwareAcceleration ?? true
);
}

async setEnableHardwareAcceleration(value: boolean, options?: StorageOptions): Promise<void> {
const globals = await this.getGlobals(
this.reconcileOptions(options, await this.defaultOnDiskOptions())
);
globals.enableHardwareAcceleration = value;
await this.saveGlobals(
globals,
this.reconcileOptions(options, await this.defaultOnDiskOptions())
);
}

async getEncryptedCiphers(options?: StorageOptions): Promise<{ [id: string]: CipherData }> {
return (
await this.getAccount(this.reconcileOptions(options, await this.defaultOnDiskMemoryOptions()))
Expand Down
4 changes: 4 additions & 0 deletions libs/common/src/services/stateMigration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const v1Keys: { [key: string]: string } = {
enableMinimizeToTray: "enableMinimizeToTray",
enableStartToTray: "enableStartToTrayKey",
enableTray: "enableTray",
enableHardwareAcceleration: "enableHardwareAcceleration",
Copy link
Member

Choose a reason for hiding this comment

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

I don't believe we'll need a state migration for this. It's a new option that wasn't available before the migration.

encKey: "encKey", // Generated Symmetric Key
encOrgKeys: "encOrgKeys",
encPrivate: "encPrivateKey",
Expand Down Expand Up @@ -225,6 +226,9 @@ export class StateMigrationService<
globals.enableBrowserIntegrationFingerprint =
(await this.get<boolean>(v1Keys.enableBrowserIntegrationFingerprint)) ??
globals.enableBrowserIntegrationFingerprint;
globals.enableHardwareAcceleration =
(await this.get<boolean>(v1Keys.enableHardwareAcceleration)) ??
globals.enableHardwareAcceleration;

const userId =
(await this.get<string>(v1Keys.userId)) ?? (await this.get<string>(v1Keys.entityId));
Expand Down