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

Add "Enable GPU hardware acceleration" option #734

Merged
merged 2 commits into from
Mar 22, 2018
Merged
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
25 changes: 25 additions & 0 deletions src/browser/components/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -549,6 +557,23 @@ const SettingsPage = createReactClass({
</Checkbox>);
}

options.push(
<Checkbox
key='inputEnableHardwareAcceleration'
id='inputEnableHardwareAcceleration'
ref='enableHardwareAcceleration'
checked={this.state.enableHardwareAcceleration}
onChange={this.handleChangeEnableHardwareAcceleration}
>
{'Use GPU hardware acceleration'}
<HelpBlock>
{'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.'}
</HelpBlock>
</Checkbox>
);

var optionsRow = (options.length > 0) ? (
<Row>
<Col md={12}>
Expand Down
1 change: 1 addition & 0 deletions src/common/config/defaultPreferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const defaultPreferences = {
},
showUnreadBadge: true,
useSpellChecker: true,
enableHardwareAcceleration: true,
};

module.exports = defaultPreferences;
4 changes: 4 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 24 additions & 1 deletion test/specs/browser/settings_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -281,6 +280,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', () => {
Expand Down