From ef9cd8cd2460007f8fae9afa534dcc20fedab582 Mon Sep 17 00:00:00 2001 From: TC Date: Wed, 2 Dec 2020 22:07:15 +0100 Subject: [PATCH] Add option to disable hardware acceleration --- index.js | 7 +++++++ menu.js | 9 +++++++++ store/index.js | 3 +++ 3 files changed, 19 insertions(+) diff --git a/index.js b/index.js index 318eb499..de4218d3 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ const { autoUpdater } = require("electron-updater"); const { setApplicationMenu } = require("./menu"); const { autoUpdate, + disableHardwareAcceleration, getEnabledPlugins, hideMenu, isAppVisible, @@ -27,6 +28,12 @@ app.commandLine.appendSwitch( "--experimental-wasm-threads --experimental-wasm-bulk-memory" ); app.allowRendererProcessReuse = true; // https://github.com/electron/electron/issues/18397 +if (disableHardwareAcceleration()) { + if (is.dev()) { + console.log("Disabling hardware acceleration"); + } + app.disableHardwareAcceleration(); +} // Adds debug features like hotkeys for triggering dev tools and reload require("electron-debug")(); diff --git a/menu.js b/menu.js index 0af131cb..0932238c 100644 --- a/menu.js +++ b/menu.js @@ -12,6 +12,7 @@ const { isTrayEnabled, setOptions, startAtLogin, + disableHardwareAcceleration, } = require("./store"); const mainMenuTemplate = (win) => [ @@ -43,6 +44,14 @@ const mainMenuTemplate = (win) => [ setOptions({ autoUpdates: item.checked }); }, }, + { + label: "Disable hardware acceleration", + type: "checkbox", + checked: disableHardwareAcceleration(), + click: (item) => { + setOptions({ disableHardwareAcceleration: item.checked }); + }, + }, ...(is.windows() || is.linux() ? [ { diff --git a/store/index.js b/store/index.js index 659d5bea..b49681cb 100644 --- a/store/index.js +++ b/store/index.js @@ -15,6 +15,7 @@ const store = new Store({ autoUpdates: true, hideMenu: false, startAtLogin: false, + disableHardwareAcceleration: false, }, }, }); @@ -34,4 +35,6 @@ module.exports = { autoUpdate: () => store.get("options.autoUpdates"), hideMenu: () => store.get("options.hideMenu"), startAtLogin: () => store.get("options.startAtLogin"), + disableHardwareAcceleration: () => + store.get("options.disableHardwareAcceleration"), };