From b737e63f68876aa1f936c2325913621c0e8abf81 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Tue, 20 Mar 2018 22:24:07 +0900 Subject: [PATCH 1/2] Add "Enable GPU hardware acceleration" option --- src/browser/components/SettingsPage.jsx | 25 +++++++++++++++++++++++++ src/common/config/defaultPreferences.js | 1 + src/main.js | 4 ++++ test/specs/browser/settings_test.js | 24 ++++++++++++++++++++++++ 4 files changed, 54 insertions(+) diff --git a/src/browser/components/SettingsPage.jsx b/src/browser/components/SettingsPage.jsx index bac0278f99f..43b590a1054 100644 --- a/src/browser/components/SettingsPage.jsx +++ b/src/browser/components/SettingsPage.jsx @@ -136,6 +136,7 @@ const SettingsPage = createReactClass({ showUnreadBadge: this.state.showUnreadBadge, useSpellChecker: this.state.useSpellChecker, spellCheckerLocale: this.state.spellCheckerLocale, + enableHardwareAcceleration: this.state.enableHardwareAcceleration, }; settings.writeFile(this.props.configFile, config, (err) => { @@ -259,6 +260,13 @@ const SettingsPage = createReactClass({ setImmediate(this.startSaveConfig, CONFIG_TYPE_APP_OPTIONS); }, + handleChangeEnableHardwareAcceleration() { + this.setState({ + enableHardwareAcceleration: !this.refs.enableHardwareAcceleration.props.checked, + }); + setImmediate(this.startSaveConfig, CONFIG_TYPE_APP_OPTIONS); + }, + updateTeam(index, newData) { var teams = this.state.teams; teams[index] = newData; @@ -549,6 +557,23 @@ const SettingsPage = createReactClass({ ); } + options.push( + + {'Use GPU hardware acceleration'} + + {'Disable this setting if you see a blank page after logging in to Mattermost.'} + {' If enabled, the Mattermost UI is rendered more efficiently but can cause stability issues for some systems.'} + {' Setting takes affect after restarting the app.'} + + + ); + var optionsRow = (options.length > 0) ? ( diff --git a/src/common/config/defaultPreferences.js b/src/common/config/defaultPreferences.js index 4cd63e42ba8..774422c0d91 100644 --- a/src/common/config/defaultPreferences.js +++ b/src/common/config/defaultPreferences.js @@ -15,6 +15,7 @@ const defaultPreferences = { }, showUnreadBadge: true, useSpellChecker: true, + enableHardwareAcceleration: true, }; module.exports = defaultPreferences; diff --git a/src/main.js b/src/main.js index 950ba494796..8dded7185b8 100644 --- a/src/main.js +++ b/src/main.js @@ -88,6 +88,10 @@ try { settings.writeFileSync(configFile, config); } } +if (config.enableHardwareAcceleration === false) { + app.disableHardwareAcceleration(); +} + ipcMain.on('update-config', () => { const configFile = app.getPath('userData') + '/config.json'; config = settings.readFileSync(configFile); diff --git a/test/specs/browser/settings_test.js b/test/specs/browser/settings_test.js index a615f7feaae..8ffc8b9bc45 100644 --- a/test/specs/browser/settings_test.js +++ b/test/specs/browser/settings_test.js @@ -281,6 +281,30 @@ describe('browser/settings.html', function desc() { config1.useSpellChecker.should.equal(false); }); }); + + describe('Enable GPU hardware acceleration', () => { + it('should save selected option', async () => { + const ID_INPUT_ENABLE_HARDWARE_ACCELERATION = '#inputEnableHardwareAcceleration'; + env.addClientCommands(this.app.client); + await this.app.client. + loadSettingsPage(). + waitForExist(ID_INPUT_ENABLE_HARDWARE_ACCELERATION, 5000); + const selected = await this.app.client.isSelected(ID_INPUT_ENABLE_HARDWARE_ACCELERATION); + selected.should.equal(true); + + await this.app.client.click(ID_INPUT_ENABLE_HARDWARE_ACCELERATION). + waitForVisible('#appOptionsSaveIndicator', 5000). + waitForVisible('#appOptionsSaveIndicator', 5000, true); // at least 2500 ms to disappear + const config0 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8')); + config0.enableHardwareAcceleration.should.equal(false); + + await this.app.client.click(ID_INPUT_ENABLE_HARDWARE_ACCELERATION). + waitForVisible('#appOptionsSaveIndicator', 5000). + waitForVisible('#appOptionsSaveIndicator', 5000, true); // at least 2500 ms to disappear + const config1 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8')); + config1.enableHardwareAcceleration.should.equal(true); + }); + }); }); describe('RemoveServerModal', () => { From 570b256da9a18cfad352be2a499fc82a29b479aa Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Tue, 20 Mar 2018 23:12:00 +0900 Subject: [PATCH 2/2] Stop using scroll in test --- test/specs/browser/settings_test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/specs/browser/settings_test.js b/test/specs/browser/settings_test.js index 8ffc8b9bc45..df018d1a790 100644 --- a/test/specs/browser/settings_test.js +++ b/test/specs/browser/settings_test.js @@ -272,7 +272,6 @@ describe('browser/settings.html', function desc() { const existing = await this.app.client.isExisting('#inputSpellChecker'); existing.should.equal(true); - await this.app.client.scroll('#inputSpellChecker'); const selected = await this.app.client.isSelected('#inputSpellChecker'); selected.should.equal(true);