mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-21 16:38:41 -06:00
SDA-1880 & SDA-1882 - Fix background throttling issue (#925)
This commit is contained in:
parent
79b2c42fdc
commit
996bd858a7
@ -20,7 +20,7 @@
|
||||
"customFlags": {
|
||||
"authServerWhitelist": "",
|
||||
"authNegotiateDelegateWhitelist": "",
|
||||
"disableThrottling": false
|
||||
"disableThrottling": "DISABLED"
|
||||
},
|
||||
"permissions": {
|
||||
"media": true,
|
||||
|
@ -5,17 +5,27 @@ import { app } from './__mocks__/electron';
|
||||
|
||||
jest.mock('../src/app/config-handler', () => {
|
||||
return {
|
||||
CloudConfigDataTypes: {
|
||||
NOT_SET: 'NOT_SET',
|
||||
ENABLED: 'ENABLED',
|
||||
DISABLED: 'DISABLED',
|
||||
},
|
||||
config: {
|
||||
getConfigFields: jest.fn(() => {
|
||||
return {
|
||||
customFlags: {
|
||||
authServerWhitelist: 'url',
|
||||
authNegotiateDelegateWhitelist: 'whitelist',
|
||||
disableThrottling: false,
|
||||
disableThrottling: 'DISABLED',
|
||||
},
|
||||
disableGpu: true,
|
||||
};
|
||||
}),
|
||||
getCloudConfigFields: jest.fn(() => {
|
||||
return {
|
||||
disableThrottling: 'DISABLED',
|
||||
};
|
||||
}),
|
||||
},
|
||||
};
|
||||
});
|
||||
@ -75,6 +85,79 @@ describe('chrome flags', () => {
|
||||
expect(spy).not.nthCalledWith(4);
|
||||
});
|
||||
|
||||
it('should set `disable-renderer-backgrounding` chrome flag correctly when cloud config is ENABLED', () => {
|
||||
config.getConfigFields = jest.fn(() => {
|
||||
return {
|
||||
customFlags: {
|
||||
authServerWhitelist: 'url',
|
||||
authNegotiateDelegateWhitelist: 'whitelist',
|
||||
disableGpu: false,
|
||||
disableThrottling: 'ENABLED',
|
||||
},
|
||||
};
|
||||
});
|
||||
const spy = jest.spyOn(app.commandLine, 'appendSwitch');
|
||||
setChromeFlags();
|
||||
expect(spy).nthCalledWith(4, 'disable-renderer-backgrounding', 'true');
|
||||
expect(spy).not.nthCalledWith(5);
|
||||
});
|
||||
|
||||
it('should set `disable-renderer-backgrounding` chrome flag correctly when cloud config PMP setting is ENABLED', () => {
|
||||
config.getCloudConfigFields = jest.fn(() => {
|
||||
return {
|
||||
disableThrottling: 'ENABLED',
|
||||
};
|
||||
});
|
||||
const spy = jest.spyOn(app.commandLine, 'appendSwitch');
|
||||
setChromeFlags();
|
||||
expect(spy).nthCalledWith(7, 'disable-renderer-backgrounding', 'true');
|
||||
expect(spy).not.nthCalledWith(8);
|
||||
});
|
||||
|
||||
it('should set `disable-renderer-backgrounding` chrome flag when any one is ENABLED ', () => {
|
||||
config.getConfigFields = jest.fn(() => {
|
||||
return {
|
||||
customFlags: {
|
||||
authServerWhitelist: 'url',
|
||||
authNegotiateDelegateWhitelist: 'whitelist',
|
||||
disableGpu: false,
|
||||
disableThrottling: 'DISABLED',
|
||||
},
|
||||
};
|
||||
});
|
||||
config.getCloudConfigFields = jest.fn(() => {
|
||||
return {
|
||||
disableThrottling: 'ENABLED',
|
||||
};
|
||||
});
|
||||
const spy = jest.spyOn(app.commandLine, 'appendSwitch');
|
||||
setChromeFlags();
|
||||
expect(spy).nthCalledWith(4, 'disable-renderer-backgrounding', 'true');
|
||||
expect(spy).not.nthCalledWith(5);
|
||||
});
|
||||
|
||||
it('should set `disable-renderer-backgrounding` chrome flag when PMP is ENABLED', () => {
|
||||
config.getConfigFields = jest.fn(() => {
|
||||
return {
|
||||
customFlags: {
|
||||
authServerWhitelist: 'url',
|
||||
authNegotiateDelegateWhitelist: 'whitelist',
|
||||
disableGpu: false,
|
||||
disableThrottling: 'ENABLED',
|
||||
},
|
||||
};
|
||||
});
|
||||
config.getCloudConfigFields = jest.fn(() => {
|
||||
return {
|
||||
disableThrottling: 'DISABLED',
|
||||
};
|
||||
});
|
||||
const spy = jest.spyOn(app.commandLine, 'appendSwitch');
|
||||
setChromeFlags();
|
||||
expect(spy).nthCalledWith(4, 'disable-renderer-backgrounding', 'true');
|
||||
expect(spy).not.nthCalledWith(5);
|
||||
});
|
||||
|
||||
describe('`isDevEnv`', () => {
|
||||
beforeEach(() => {
|
||||
(isDevEnv as any) = true;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { app, session } from 'electron';
|
||||
|
||||
import { logger } from '../common/logger';
|
||||
import { config, IConfig } from './config-handler';
|
||||
import { CloudConfigDataTypes, config, IConfig } from './config-handler';
|
||||
|
||||
// Set default flags
|
||||
logger.info(`chrome-flags: Setting mandatory chrome flags`, { flag: { 'ssl-version-fallback-min': 'tls1.2' } });
|
||||
@ -17,6 +17,7 @@ export const setChromeFlags = () => {
|
||||
logger.info(`chrome-flags: Checking if we need to set chrome flags!`);
|
||||
|
||||
const flagsConfig = config.getConfigFields(['customFlags', 'disableGpu']) as IConfig;
|
||||
const { disableThrottling } = config.getCloudConfigFields([ 'disableThrottling' ]) as any;
|
||||
const configFlags: object = {
|
||||
'auth-negotiate-delegate-whitelist': flagsConfig.customFlags.authServerWhitelist,
|
||||
'auth-server-whitelist': flagsConfig.customFlags.authNegotiateDelegateWhitelist,
|
||||
@ -24,8 +25,10 @@ export const setChromeFlags = () => {
|
||||
'disable-d3d11': flagsConfig.disableGpu || null,
|
||||
'disable-gpu': flagsConfig.disableGpu || null,
|
||||
'disable-gpu-compositing': flagsConfig.disableGpu || null,
|
||||
'disable-renderer-backgrounding': flagsConfig.customFlags.disableThrottling || null,
|
||||
};
|
||||
if (flagsConfig.customFlags.disableThrottling === CloudConfigDataTypes.ENABLED || disableThrottling === CloudConfigDataTypes.ENABLED) {
|
||||
configFlags['disable-renderer-backgrounding'] = 'true';
|
||||
}
|
||||
|
||||
for (const key in configFlags) {
|
||||
if (!Object.prototype.hasOwnProperty.call(configFlags, key)) {
|
||||
|
@ -94,7 +94,7 @@ export interface IPermission {
|
||||
export interface ICustomFlag {
|
||||
authServerWhitelist: string;
|
||||
authNegotiateDelegateWhitelist: string;
|
||||
disableThrottling: boolean;
|
||||
disableThrottling: CloudConfigDataTypes;
|
||||
}
|
||||
|
||||
export interface INotificationSetting {
|
||||
@ -150,8 +150,9 @@ class Config {
|
||||
* @param fields
|
||||
*/
|
||||
public getConfigFields(fields: string[]): IConfig {
|
||||
logger.info(`config-handler: Trying to get cloud config values for the fields`, fields);
|
||||
return { ...this.getGlobalConfigFields(fields), ...this.getUserConfigFields(fields), ...this.getFilteredCloudConfigFields(fields) } as IConfig;
|
||||
const configFields = { ...this.getGlobalConfigFields(fields), ...this.getUserConfigFields(fields), ...this.getFilteredCloudConfigFields(fields) } as IConfig;
|
||||
logger.info(`config-handler: getting combined config values for the fields ${fields}`, configFields);
|
||||
return configFields;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,8 +161,9 @@ class Config {
|
||||
* @param fields {Array}
|
||||
*/
|
||||
public getUserConfigFields(fields: string[]): IConfig {
|
||||
logger.info(`config-handler: Trying to get user config values for the fields`, fields);
|
||||
return pick(this.userConfig, fields) as IConfig;
|
||||
const userConfigData = pick(this.userConfig, fields) as IConfig;
|
||||
logger.info(`config-handler: getting user config values for the fields ${fields}`, userConfigData);
|
||||
return userConfigData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,8 +172,9 @@ class Config {
|
||||
* @param fields {Array}
|
||||
*/
|
||||
public getGlobalConfigFields(fields: string[]): IGlobalConfig {
|
||||
logger.info(`config-handler: Trying to get global config values for the fields`, fields);
|
||||
return pick(this.globalConfig, fields) as IGlobalConfig;
|
||||
const globalConfigData = pick(this.globalConfig, fields) as IGlobalConfig;
|
||||
logger.info(`config-handler: getting global config values for the fields ${fields}`, globalConfigData);
|
||||
return globalConfigData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -180,7 +183,9 @@ class Config {
|
||||
* @param fields {Array}
|
||||
*/
|
||||
public getFilteredCloudConfigFields(fields: string[]): IConfig | {} {
|
||||
return pick(this.filteredCloudConfig, fields) as IConfig;
|
||||
const filteredCloudConfigData = pick(this.filteredCloudConfig, fields) as IConfig;
|
||||
logger.info(`config-handler: getting filtered cloud config values for the ${fields}`, filteredCloudConfigData);
|
||||
return filteredCloudConfigData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -190,7 +195,10 @@ class Config {
|
||||
public getCloudConfigFields(fields: string[]): IConfig {
|
||||
const { acpFeatureLevelEntitlements, podLevelEntitlements, pmpEntitlements } = this.cloudConfig as ICloudConfig;
|
||||
const cloudConfig = { ...acpFeatureLevelEntitlements, ...podLevelEntitlements, ...pmpEntitlements };
|
||||
return pick(cloudConfig, fields) as IConfig;
|
||||
logger.info(`config-handler: prioritized cloud config data`, cloudConfig);
|
||||
const cloudConfigData = pick(cloudConfig, fields) as IConfig;
|
||||
logger.info(`config-handler: getting prioritized cloud config values for the fields ${fields}`, cloudConfigData);
|
||||
return cloudConfigData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -223,7 +231,7 @@ class Config {
|
||||
logger.info(`config-handler: prioritized and filtered cloud config: `, this.filteredCloudConfig);
|
||||
try {
|
||||
await writeFile(this.cloudConfigPath, JSON.stringify(this.cloudConfig), { encoding: 'utf8' });
|
||||
logger.info(`config-handler: writting cloud config values to file`);
|
||||
logger.info(`config-handler: writing cloud config values to file`);
|
||||
} catch (error) {
|
||||
logger.error(`config-handler: failed to update cloud config file with ${data}`, error);
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
import { powerSaveBlocker } from 'electron';
|
||||
import { logger } from '../common/logger';
|
||||
import { config, IConfig } from './config-handler';
|
||||
import { CloudConfigDataTypes, config, IConfig } from './config-handler';
|
||||
|
||||
export const handlePerformanceSettings = () => {
|
||||
const { customFlags } = config.getCloudConfigFields([ 'customFlags' ]) as IConfig;
|
||||
const { disableThrottling } = config.getCloudConfigFields([ 'disableThrottling' ]) as any;
|
||||
|
||||
if (customFlags && customFlags.disableThrottling) {
|
||||
if ((customFlags && customFlags.disableThrottling === CloudConfigDataTypes.ENABLED) || disableThrottling === CloudConfigDataTypes.ENABLED) {
|
||||
logger.info(`perf-handler: Disabling power throttling!`);
|
||||
powerSaveBlocker.start('prevent-display-sleep');
|
||||
return;
|
||||
|
@ -96,12 +96,13 @@ export class WindowHandler {
|
||||
this.config = config.getConfigFields([ 'isCustomTitleBar', 'mainWinPos', 'minimizeOnClose', 'notificationSettings', 'alwaysOnTop', 'locale', 'customFlags' ]);
|
||||
logger.info(`window-handler: main windows initialized with following config data`, this.config);
|
||||
this.globalConfig = config.getGlobalConfigFields([ 'url', 'contextIsolation' ]);
|
||||
const { disableThrottling } = config.getCloudConfigFields([ 'disableThrottling' ]) as any;
|
||||
const { url, contextIsolation }: IGlobalConfig = this.globalConfig;
|
||||
const { customFlags } = this.config;
|
||||
|
||||
this.windows = {};
|
||||
this.contextIsolation = contextIsolation || false;
|
||||
this.backgroundThrottling = !customFlags.disableThrottling;
|
||||
this.backgroundThrottling = (customFlags.disableThrottling !== CloudConfigDataTypes.ENABLED || disableThrottling !== CloudConfigDataTypes.ENABLED);
|
||||
this.isCustomTitleBar = isWindowsOS && this.config.isCustomTitleBar === CloudConfigDataTypes.ENABLED;
|
||||
this.windowOpts = {
|
||||
...this.getWindowOpts({
|
||||
|
Loading…
Reference in New Issue
Block a user