1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

[PM-3316] Feature addition - Toggle Hardware Acceleration [Desktop] (#5968)

Added a toggle for disabling/enabling hardware acceleration on Desktop client.

Resolves #2615

---------

Co-authored-by: Hinton <hinton@users.noreply.github.com>
This commit is contained in:
Prithvi Reddy
2024-03-21 19:13:29 +05:30
committed by GitHub
parent e80ee2ec55
commit cd5dc09d25
7 changed files with 84 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
import * as path from "path";
import { app } from "electron";
import { firstValueFrom } from "rxjs";
import { TokenService as TokenServiceAbstraction } from "@bitwarden/common/auth/abstractions/token.service";
import { AccountServiceImplementation } from "@bitwarden/common/auth/services/account.service";
@@ -37,6 +38,7 @@ import { BiometricsService, BiometricsServiceAbstraction } from "./platform/main
import { ClipboardMain } from "./platform/main/clipboard.main";
import { DesktopCredentialStorageListener } from "./platform/main/desktop-credential-storage-listener";
import { MainCryptoFunctionService } from "./platform/main/main-crypto-function.service";
import { DesktopSettingsService } from "./platform/services/desktop-settings.service";
import { ElectronLogMainService } from "./platform/services/electron-log.main.service";
import { ELECTRON_SUPPORTS_SECURE_STORAGE } from "./platform/services/electron-platform-utils.service";
import { ElectronStateService } from "./platform/services/electron-state.service";
@@ -56,6 +58,7 @@ export class Main {
mainCryptoFunctionService: MainCryptoFunctionService;
desktopCredentialStorageListener: DesktopCredentialStorageListener;
migrationRunner: MigrationRunner;
desktopSettingsService: DesktopSettingsService;
tokenService: TokenServiceAbstraction;
windowMain: WindowMain;
@@ -189,6 +192,7 @@ export class Main {
this.messagingMain = new MessagingMain(this, this.stateService);
this.updaterMain = new UpdaterMain(this.i18nService, this.windowMain);
this.trayMain = new TrayMain(this.windowMain, this.i18nService, this.stateService);
this.desktopSettingsService = new DesktopSettingsService(stateProvider);
this.messagingService = new ElectronMainMessagingService(this.windowMain, (message) => {
this.messagingMain.onMessage(message);
@@ -237,6 +241,7 @@ export class Main {
// Run migrations first, then other things
this.migrationRunner.run().then(
async () => {
await this.toggleHardwareAcceleration();
await this.windowMain.init();
await this.i18nService.init();
this.messagingMain.init();
@@ -307,4 +312,15 @@ export class Main {
this.messagingService.send("deepLink", { urlString: s });
});
}
private async toggleHardwareAcceleration(): Promise<void> {
const hardwareAcceleration = await firstValueFrom(
this.desktopSettingsService.hardwareAcceleration$,
);
if (!hardwareAcceleration) {
this.logService.warning("Hardware acceleration is disabled");
app.disableHardwareAcceleration();
}
}
}