mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
ELECTRON-870 - Remove process.getCPUUsage from renderer process due to sandbox
This commit is contained in:
parent
13651e2a81
commit
4737a9135f
@ -153,10 +153,10 @@ electron.ipcMain.on(apiName, (event, arg) => {
|
|||||||
}
|
}
|
||||||
case apiCmds.optimizeMemoryConsumption:
|
case apiCmds.optimizeMemoryConsumption:
|
||||||
if (typeof arg.memory === 'object'
|
if (typeof arg.memory === 'object'
|
||||||
&& typeof arg.cpuUsage === 'object'
|
|
||||||
&& typeof arg.memory.workingSetSize === 'number'
|
&& typeof arg.memory.workingSetSize === 'number'
|
||||||
&& typeof arg.activeRequests === 'number') {
|
&& typeof arg.activeRequests === 'number') {
|
||||||
setPreloadMemoryInfo(arg.memory, arg.cpuUsage, arg.activeRequests);
|
log.send(logLevels.INFO, 'Received memory info from renderer');
|
||||||
|
setPreloadMemoryInfo(arg.memory, arg.activeRequests);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case apiCmds.optimizeMemoryRegister:
|
case apiCmds.optimizeMemoryRegister:
|
||||||
|
@ -9,6 +9,7 @@ const { getConfigField } = require('./config');
|
|||||||
|
|
||||||
const maxMemory = 800;
|
const maxMemory = 800;
|
||||||
const defaultInterval = 30 * 1000;
|
const defaultInterval = 30 * 1000;
|
||||||
|
const defaultIntervalSymLock = 10 * 1000;
|
||||||
const memoryRefreshThreshold = 60 * 60 * 1000;
|
const memoryRefreshThreshold = 60 * 60 * 1000;
|
||||||
const cpuUsageThreshold = 5;
|
const cpuUsageThreshold = 5;
|
||||||
|
|
||||||
@ -84,7 +85,8 @@ function optimizeMemory() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
log.send(logLevels.INFO, `Not Reloading the app as
|
log.send(logLevels.INFO, `Not Reloading the app as
|
||||||
|
application was refreshed less than a hour ago? ${canReload ? 'no' : 'yes'}
|
||||||
memory consumption was ${memoryConsumed}
|
memory consumption was ${memoryConsumed}
|
||||||
CPU usage percentage was ${preloadMemory.cpuUsage.percentCPUUsage}
|
CPU usage percentage was ${preloadMemory.cpuUsage.percentCPUUsage}
|
||||||
user was in a meeting? ${isInMeeting}
|
user was in a meeting? ${isInMeeting}
|
||||||
@ -105,11 +107,11 @@ function setIsInMeeting(meetingStatus) {
|
|||||||
* Sets preload memory info and calls optimize memory func
|
* Sets preload memory info and calls optimize memory func
|
||||||
*
|
*
|
||||||
* @param memoryInfo - memory consumption of the preload main script
|
* @param memoryInfo - memory consumption of the preload main script
|
||||||
* @param cpuUsage - CPU usage of the preload main script
|
|
||||||
* @param activeRequests - pending active network requests on the client
|
* @param activeRequests - pending active network requests on the client
|
||||||
*/
|
*/
|
||||||
function setPreloadMemoryInfo(memoryInfo, cpuUsage, activeRequests) {
|
function setPreloadMemoryInfo(memoryInfo, activeRequests) {
|
||||||
log.send(logLevels.INFO, 'Memory info received from preload process now running optimize memory logic');
|
log.send(logLevels.INFO, 'Memory info received from preload process now running optimize memory logic');
|
||||||
|
const cpuUsage = process.getCPUUsage();
|
||||||
preloadMemory = { memoryInfo, cpuUsage, activeRequests };
|
preloadMemory = { memoryInfo, cpuUsage, activeRequests };
|
||||||
optimizeMemory();
|
optimizeMemory();
|
||||||
}
|
}
|
||||||
@ -119,6 +121,7 @@ function setPreloadMemoryInfo(memoryInfo, cpuUsage, activeRequests) {
|
|||||||
* and waits for 30s to optimize memory
|
* and waits for 30s to optimize memory
|
||||||
*/
|
*/
|
||||||
eventEmitter.on('appMinimized', () => {
|
eventEmitter.on('appMinimized', () => {
|
||||||
|
log.send(logLevels.INFO, 'Application was minimised');
|
||||||
appMinimizedTimer = setTimeout(() => {
|
appMinimizedTimer = setTimeout(() => {
|
||||||
const mainWindow = getMainWindow();
|
const mainWindow = getMainWindow();
|
||||||
if (mainWindow && !mainWindow.isDestroyed() && mainWindow.isMinimized()) {
|
if (mainWindow && !mainWindow.isDestroyed() && mainWindow.isMinimized()) {
|
||||||
@ -151,7 +154,7 @@ eventEmitter.on('sys-locked', () => {
|
|||||||
powerMonitorTimer = setTimeout(() => {
|
powerMonitorTimer = setTimeout(() => {
|
||||||
log.send(logLevels.INFO, 'System screen was locked for more than 30s so calling requestMemoryInfo');
|
log.send(logLevels.INFO, 'System screen was locked for more than 30s so calling requestMemoryInfo');
|
||||||
requestMemoryInfo();
|
requestMemoryInfo();
|
||||||
}, defaultInterval);
|
}, defaultIntervalSymLock);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -505,12 +505,10 @@ function createAPI() {
|
|||||||
local.ipcRenderer.on('memory-info-request', () => {
|
local.ipcRenderer.on('memory-info-request', () => {
|
||||||
if (window.name === 'main') {
|
if (window.name === 'main') {
|
||||||
const memory = process.getProcessMemoryInfo();
|
const memory = process.getProcessMemoryInfo();
|
||||||
const cpuUsage = process.getCPUUsage();
|
const activeRequests = typeof local.activeRequests === 'function' ? local.activeRequests() : 0;
|
||||||
const activeRequests = local.activeRequests();
|
|
||||||
local.ipcRenderer.send(apiName, {
|
local.ipcRenderer.send(apiName, {
|
||||||
cmd: apiCmds.optimizeMemoryConsumption,
|
cmd: apiCmds.optimizeMemoryConsumption,
|
||||||
memory,
|
memory,
|
||||||
cpuUsage,
|
|
||||||
activeRequests,
|
activeRequests,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user